Forum Moderators: phranque
Only thing different from before is that I'm not hosting it myself, and instead using a US based hosting company.
I created the .htacces file with some mod_rewrite conditions known to work, just to make sure it does in fact work, but it doesn't seem to.
I contacted the host, asking if mod_rewrite was enabled, and they assured me it was.
I've tried using some very basic conditions, and still no luck. This is what I've used to test:
Options +FollowSymLinks
rewriteEngine On
rewriteRule ^test.htm$ test.php [L]
Should this not work if in fact mod_rewrite was enabled?
Now, I've contacted support again and they claim mod_rewrite is enabled. They've said they don't do troubleshooting, as it must be an error on my part.
My question is this: how can I test with no uncertainty that mod_rewrite does in fact work, or somehow be sure it doesn't, so I can ask them again?
Thank you...
Welcome to WebmasterWorld!
1) Try it with two static html pages -- rewrite 'test.htm' to 'test2.htm'. This eliminates php from the equation.
2) Now test your test.php file by accessing it directly.
3) Check your server error log. Be sure that you are allowed to use the Options directive.
If all the above are correct, then it's likely that there is an error in the LoadModule list order; The php module must be loaded before mod_rewrite. Execution priority is the reverse of the LoadModule order. If the php module is loaded after mod_rewrite, then it will execute before mod_rewrite, making it impossible to do rewrites involving php files.
Another tip. It's sometimes handy to temporarily change rewrites into redirects, so that you can see the process in your browser address bar. Internal variables can also be appended to the redirected URL as a query string to make them visible in your address bar. In simple cases such as the above, this shouldn't be needed, though.
Jim
RewriteRule ^test.htm$ test.php [L]
In the .htaccess file the correct syntax is:
RewriteRule ^test\.htm$ /test.php [L]
In the httpd.conf file the correct syntax is:
RewriteRule ^/test\.htm$ test.php [L]
Guessing if your server is not Screaming Error at you that a symple syntax error is the cause of the problem.
Justin
Actually, I did initially use the \. syntax, but forget it in the text here.
I've tried the suggested approaches, and still no luck.
Not even test.htm -> test2.htm works.
As it is a standard hosting plan, I have no access to logs.
My goal right now is to establish with no doubt that mod_rewrite isn't enabled, so I can tell them. They haven't exactly been forthcomming so far, so I wan't to make sure I'm right about this.
Put this is the root (main, usually http_docs, www, or yoursite.com) .htaccess file, above all other lines of code.
RewriteEngine ON
RewriteRule .* - [F]
Depending on server configuration you may need either or both of the following:
AllowOverride FileInfo
Options +FollowSymLinks
So, your final file may look like this:
AllowOverride FileInfo
Options +FollowSymLinks
RewriteEngine ON
RewriteRule .* - [F]
*DO NOT* test this when you expect traffic. If mod_rewrite is enabled, you will serve a FORBIDEN error for every page. If it is not you should be able to access your pages as usual... This is ususally a definitive test.
Justin
Added: If you are uploading, make sure you select ASCII encoding, and edit in a plain text editor with NO formating. If you have the option, use UNIX line breaks.
I cannot recommend that you use any mod_rewrite code or scripts on a server where you have no access to error logs. It is simply too difficult to detect and debug problems without log access. I strongly suggest that you confirm with your host that you don't have error log access, and if this is the case, then choose between not using advanced driectives or finding a better host.
Best,
Jim
I started out trying this one:
AllowOverride FileInfo
Options +FollowSymLinks
RewriteEngine ON
RewriteRule .* - [F]
That gave me an error (not 404), so i tried removing the first 2 lines, and then - all of a sudden - it works!
I got the 'Forbidden Page', and then moved back to the test.htm -> test2.htm. That now works and after having tried all my other rewrite rules, it's as if a switch has been turned on and everything now works...
I'm not quite sure what to think of this, but at least it works, and I thank you.
Should I feel secure that this is enabled now or could the 'AllowOverride FileInfo' part have switched something on, that will be gone when Apache restarts?
(I'm not really that familiar with apache besides php)
As for the lack of logs, well I have a dedicated server elsewhere, and I've never had to look at the logs. It's running several sites with mod_rewrite, so I guess I won't switch servers right now in this case.
But in time this site will be moved to something less standard, if succesfull...