Forum Moderators: phranque
For the past several hours (I lost sense of time:)) I've been trying to make this mod_rewrite thing work - with no result!:(
After creating ".htaccess"(at first it was .txt extension but later I changed it) I chose the simpliest code there was:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^index.htm$ index.php[L]
It should convert index.php to index.htm, am I right?
But it doesn't ...:(
I have no idea what may be wrong:
- I checked phpinfo() and there is mod_rewrite module
- the "htaccess "file is in the same directory as the file.
What can be wrong? Maybe I messed something up with ".htaccess"?
BTW, is it alright if in the extension row in Total Commander there is a blank space instead of "htaccess"?
I appreciate any suggestions
Marcin
I'm pretty sure you also want to add a space before the [L].
To assist in troubleshooting, change the [L] to [R=301,L]. That will cause the address bar to change to the new url, so you can see whether your command even fired or not.
I put [R=301,L]instead of L and no troubleshooting appeared...
hm... I pretty sure that the sever just doesn't "see" the file, because this code doesn't work either:
ErrorDocument 404 index.htm
It should view the index.htm when a file doesn't exist, or is this code faulty, as well?
If somebody's got an idea, don't hesitate to post it.
Regards
Marcin
>Is your account php or asp?
php
Does your account come with a prebuilt htaccess file?
> I don't know that either, but I assume that in such case all directories would be affacted by one .htaccess only? Tell me something more, please.
The server I'm using is actually my father's and it's operated by some guy he employs... He is usally quite busy and in addiction he is paid for every hour he works so I try to keep it to minimum, you know :-)
I put [R=301,L]instead of L and no troubleshooting appeared...
Yes, it did. If the url didn't change at all then that's telling you that your code didn't even try to execute, rather than that it was executing wrong.
Let's make sure your server is even finding your .htaccess file. Open that up and put some garbage in it, just smack the keyboard. Save it and then try to load any page on your site. You ought to get an Internal Server Error page. If your page loads correctly then your server isn't even seeing your .htaccess file.
If adding the junk brings your server down, that's good, because you know your server is seeing the file and trying to run it, and from there we can proceed to trying to fix your code.
It might be named something other than .htaccess.
Failing that, I suggest contacting your webhost. If they won't help you, get another host. If you have to pull teeth to get the server to see your .htaccess file and Support can't help you then you don't want to host with those guys.
According to an article I found with Google, httpd.conf is usually in /etc/, but it's not there on my server. I couldn't find it anywhere on my server. Then again, I don't need to -- and I doubt that you need to, either.
I'd advise you to contact your host and ask them to reconfigure it for you.
#Options +FollowSymLinks
RewriteEngine On
RewriteRule ^test\.html$ http://example.com/index.php [R=301,L]
Copy and paste the above to your .htaccess (change example.com to yoursite.com), then try to open yoursite.com/test.html in your browser. If you get to index.php, everything works and your problem is a caching issue. If you are not redirected or receive an error, try uncommenting the first line (removing the #), empty your cache and try again.
My guess is it is one of the above, or as suggested before AllowOverride in the httpd.conf file is set to 'none'. (If you need to have this changed, FileInfo is usually a better choice for security than all).
Please, let us know.
Hope this helps.
Justin