Removing .html from url

painbringer_gr99

New Member
Messages
1
Reaction score
0
Points
0
I've searched the web and read various tutorials on how to do this, but none seems to be working. I tested if htaccess is working by setting a password, and it works fine, but I really can't seem to find a way to remove file extensions from the url.

So far, most of the tutorials claim this to be the solution, does my .htaccess file need to have anything else? Or just that? And if so, why isn't it working.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.html

Can anyone supply me with the full code?

Thanks for your time.
 

patriotseminar72

New Member
Messages
20
Reaction score
0
Points
0
I've searched the web and read various tutorials on how to do this, but none seems to be working. I tested if htaccess is working by setting a password, and it works fine, but I really can't seem to find a way to remove file extensions from the url.

So far, most of the tutorials claim this to be the solution, does my .htaccess file need to have anything else? Or just that? And if so, why isn't it working.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^/]+)/$ $1.html

Can anyone supply me with the full code?

Thanks for your time.

You could simply put the html file into a folder of the same name. Then rename the html file to index.html and point your links to the file :)
So something like http://yourdomain.com/games.html would go to http://yourdomain.com/games/index.html but it would work also as http://yourdomain.com/games/

Also, I recommend taking a look at this: http://corz.org/serv/tricks/htaccess2.php
But, as far as I know the htaaccess. trick does not work correctly for what you want.

Out of curiosity, why do you want to do this?
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
The server configuration on X10 currently requires that you set RewriteBase. In your root .htaccess, it would be:
Code:
RewriteBase /

A simpler alternative to rewrite-based extensionless (aka clean) URLs is to use content negotiation:
Code:
Options +MultiViews

All of this has been covered many times on these very forums.
 
Last edited:
Top