htaccess question

coversx

New Member
Messages
15
Reaction score
0
Points
0
Hi,

I'm using the following code in a htaccess file inside a directory:

Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

and when I type in a file name ending with .html it appears to manifest or create a directory name pertaining to the prefix of the file.

Is this how it's meant to work?

Thanks for any help offered.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Say the above is in public_html/test

You have a file in public_html/test named foo.html

You can type in the url yoursite.com/test/foo and go to that .html page (and the address bar does not show the .html)
 

coversx

New Member
Messages
15
Reaction score
0
Points
0
Hi,

Thanks for replying.

That is exactly what I thought would occur but all it appears to be doing is listings the contents of the directory.

I have tried the code in a .htacces file inside both the root and a sub-directory where the file is located but no change. I also tried having files in the root folder as well but no difference either.

Also, if I have only the file and no directory with the equivalent name, I get an internal server error.

I thought xbithack would have something to do with it but it does not seem to have any effect whether I delete the code or not.

Thanks again for writing.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
If you are saying you have a directory named foo also, of course it will try to go to the directory instead of the file with .html added.

And if you do not have a directory named foo but you use a url like yoursite.com/test/foo/ (with an ending "/"), yes, you will get a 500 error.
 
Top