Msg#: 3999507 posted 10:00 pm on Oct 1, 2009 (gmt 0)
Hi, I have some problems with my .htaccess file and the RewriteRule.
Yesterday everything was OK, but as I am designing more than one webpage I have decided to set up virtual hosts using apache so that I could have the physical files of each web in diferent directories. So after setting everything up Okay I have found out some problems in those webpages relating to the rewriterule. Here is the code:
RewriteEngine On Options +FollowSymlinks RewriteBase / RewriteRule ^concerts/(.*)$ ./index.php?section=concerts¶metros=$1 [L]
After that, the browser says: "The requested URL ... was not found on this server." and apache error logs says: "[Thu Oct 01 23:47:33 2009] [error] [client 127.0.0.1] File does not exist: C:/webs/MyMusicWeb/concerts
It seems that it is not making the rewriterule. Why?
Msg#: 3999507 posted 7:59 am on Oct 2, 2009 (gmt 0)
He's saying from looking at the log file the URL the server was trying to find was /concerts at the end.
I'm not sure what the . on the right side of the rule is for? RewriteRule ^concerts/(.*)$ ./index.php?section=concerts¶metros=$1 [L]
I would try: Options +FollowSymlinks RewriteEngine on RewriteRule ^concerts/(.*)$ /index.php?section=concerts¶metros=$1 [L]
The rewrite base is really unnecessary if you are going to use a / on the right side of the rule and the truth is it will probably do nothing more than confuse the issue, so I would go ahead and remove it.
Msg#: 3999507 posted 11:33 am on Oct 2, 2009 (gmt 0)
"[Thu Oct 01 23:47:33 2009] [error] [client 127.0.0.1] File does not exist: C:/webs/MyMusicWeb/concerts
If the rule did not work, and the logged information is correct, then the requested URL was apparently "example.com/concerts" with no trailing slash. Since this does not match your rule's pattern, the rule woould not have been invoked for this request.
Your rule looks "correct enough" and should work. Do be sure to completely flush (delete) your browser cache after changing any server-side code.
Msg#: 3999507 posted 11:56 am on Oct 2, 2009 (gmt 0)
Note that since you have config access on this server, you should consider putting your rewrites in the config file, since they will be executed much more efficiently in that context than in .htaccess. The only drawback to putting the code in your config file is that it will be necessary to restart the server after any change to your rule(s).
Msg#: 3999507 posted 12:07 pm on Oct 2, 2009 (gmt 0)
Thanks for the information, but all of this is only to try my web appliccations in localhost, in my computer. So I do not care very much about that kind of efficiency. Anyway, thanks a lot for your consideration and for "wasting" your time solving my problems.