Login Register






Remove .html extension filter_list
Author
Message
Remove .html extension #1
Hey guys,
I am busing developing a website for a music group and I am having a few problems.

I am trying to eliminate the .html extension at the end of the URL so it looks clean and fresh.
Quote:http://www.example.com/home.html
to > http://www.example.com/home

I searched around and I got a .htaccess code to help me however it's still not working.
Code:
.htaccess code RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\.html$ /$1 [L,R=301]

I then change the a href tag as instructed
Code:
Before: <a href="/home.html">Home</a> After: <a href="/home">Home</a> I even ttied <a href="http://www.example.com/home"</a>

But nothing happens apart from the server not being able to read the page (obviously)
and just gives me a 404 page (error)

I believe my hosting DOES allow .htaccess which editing is compatible,
does anyone have any suggestions?

Would be a major help,
thanks Ryazz.
-- Back from the dead! --
I just help people and fuck around with released programs, so.
-- White Hat Hacking --

Reply

RE: Remove .html extension #2
maybe this will help
==> http://www.addedbytes.com/articles/for-b...beginners/
==> http://corz.org/server/tricks/htaccess2.php

can't test it right now, but I think this might help

Code:
.htaccess code RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.html [NC,R=301,L]
double free()

Bitcoin Donations:
1FseigF4RPRwfDoa6XGFQmhGxmDc7Pya4r

Reply

RE: Remove .html extension #3
For me this is ok...

Quote:# The following will allow you to use URLs such as the following:
#
# example.com/anything
# example.com/anything/
#
# Which will actually serve files such as the following:
#
# example.com/anything.html
# example.com/anything.php
#
# But *only if they exist*, otherwise it will report the usual 404 error.

Options +FollowSymLinks
RewriteEngine On

# Remove trailing slashes.
# e.g. example.com/foo/ will redirect to example.com/foo
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=permanent,QSA]

# Redirect to HTML if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]

# Redirect to PHP if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]

copy for https://gist.github.com/mudge/22877

Reply

RE: Remove .html extension #4
Or only this if the server supports
Quote:.htaccess code
# ---- Make pages render without their extension in the url
Options +MultiViews

Reply