newborn Posted December 5, 2008 Share Posted December 5, 2008 Hello. Sure would appreciate some help with this voodoo. I am a total beginner with mod_rewrite. At this point I am just trying to understand whether there is something up with my syntax or something with the hosting. I have this very simple file to test if mod_rewrite is even working: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule hello\.html hello2.html </IfModule> Navigating to http://xxx.xx.xxx.xx/hello.html, the server returns this error: The requested URL /usr/home/cen887/www/htdocs/hello2.html was not found on this server. I can navigate directly to http://xxx.xx.xxx.xx/hello2.html no problem. The hosting company used this to prove that mod_rewrite was active, and it does work: RewriteEngine on RewriteRule ^(.*) http://www.google.com [L] I guess I am totally perplexed with the above error, since I know that file exists, what would keep the browser from simply navigating to that file using the htaccess file? Thank you very much for any advice! Quote Link to comment https://forums.phpfreaks.com/topic/135604-newbie-mod_rewrite-confusion/ Share on other sites More sharing options...
corbin Posted December 5, 2008 Share Posted December 5, 2008 Try: RewriteRule hello\.html /hello2.html Quote Link to comment https://forums.phpfreaks.com/topic/135604-newbie-mod_rewrite-confusion/#findComment-706501 Share on other sites More sharing options...
newborn Posted December 5, 2008 Author Share Posted December 5, 2008 Hi Corbin. That worked - thank you! Just to confirm what I am looking at... backslash is escaping the period before the file extension for hello.html forwardslash is stepping into the directory one level Correct? Quote Link to comment https://forums.phpfreaks.com/topic/135604-newbie-mod_rewrite-confusion/#findComment-706509 Share on other sites More sharing options...
corbin Posted December 6, 2008 Share Posted December 6, 2008 No. Forward slash (or \ under Windows) means root of the drive. It worked here because things are relative to the web root. For some reason then, when the / isn't put at the front, the rewrite uses the server side path. Quote Link to comment https://forums.phpfreaks.com/topic/135604-newbie-mod_rewrite-confusion/#findComment-707376 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.