Forum Moderators: phranque
I am in the process of moving hosts and am testing out the site before moving, but my .htaccess file does not want to work, it just returns a general non specific 404 error.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING} [L]
etc.
I have tried just testing by having only this rewrite rule in the file:
RewriteRule ^.*$ index.html [L]
but I just get and i just get another 404 error this time telling me:
The requested URL /home/sites/*mysite*/index.html was not found on this server
even though it does exist.
Do I need to set up a different rewriteBase? there was no need for one before.
Mark
does anyone know if it is even possible to test mod_rewrite when using a temporary test page? (where im accessing the site via the ipaddress and then account name e.g. 82.**.168.21/mysite.com)
Yes, it should be possible if the server is set up correctly.
I have tried just testing by having only this rewrite rule in the file:RewriteRule ^.*$ index.html [L]
That rule will create an infinite rewrite loop, since the substitution (index.html) will match the pattern. Try:
RewriteRule ^foo\.html$ /index.html [L]
Do I need to set up a different rewriteBase? there was no need for one before.
It's possible. The best way to determine this, and to figure out what the problem is, would be to look at the server error log file. When a RewriteBase problem exists, it is usually quite obvious when looking at the path given in the error log from which the server attempted to fetch the content. You will see a path-part missing or added to the directory/filepath in the error log for those failed requests.
For the sake of being thorough, let me just note that I'm talking about the server error log here, not the usual server access log. If no error logs are available, then you may want to reconsider a move to that host...
It seems that mod_rewrite is working, at least to some extent, because you state above that the server reported a 404 attempting to serve 'index.html'. Assuming that you requested "/" or some other URL, the rewrite had to have worked for the server to even try to serve 'index.html'. So, I'd say that after fixing the looping problem in your test rule, investigating RewriteBase would be a good idea.
Other possible approaches are:
Change the test rewrite above to an external redirect, so you can watch it work (or not).
Define a 'test' subdomain of your existing domain, and point that to the new server by defining a new A Record in your DNS Zone file. So domain.com and www.domain.com will continue to resolve to your old server, but test.domain.com will resolve to your new server. This by-passes the need to use the "82.**.168.21/mysite.com"-style addresses to test your new server without affecting your existing server, and allows for much more thorough testing of your site before making the final switch.
Jim
Imagine that you are in your current situation (rewrites not working) after a 'server upgrade' on your live site. You're losing money by the second, while waiting hours for a response from tech support and from various forums like WebmasterWorld... With that in mind, How much of an issue would you say it is if only the server access logs are available?
Look around, there are plenty of shared hosting plans with error logging available. Some place the error log in a 'logs' or 'stats' subdirectory, available via FTP and/or HTTP, while others make it available through the 'Control Panel".
Jim