Welcome to WebmasterWorld Guest from 54.196.175.173

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Virtual Host and RewriteRule

rewriterule

     

Blade_Stom

10:00 pm on Oct 1, 2009 (gmt 0)

5+ Year Member



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&parametros=$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?

jdMorgan

2:17 am on Oct 2, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Because your rule requires a slash after "concerts", and you typed only "concerts" as the URL-path according to the logged info above.

Jim

Blade_Stom

7:33 am on Oct 2, 2009 (gmt 0)

5+ Year Member



Im sorry but I cannot understand. I think my rule has a slash after concerts:

RewriteRule ^concerts/(.*)$ ...................

Blade_Stom

7:41 am on Oct 2, 2009 (gmt 0)

5+ Year Member



If you refers to the path written in the browser, I wrote this:
[myweb.local.com...]

jd01

7:59 am on Oct 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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&parametros=$1 [L]

I would try:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^concerts/(.*)$ /index.php?section=concerts&parametros=$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.

jdMorgan

11:33 am on Oct 2, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



"[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.

Jim

Blade_Stom

11:42 am on Oct 2, 2009 (gmt 0)

5+ Year Member



I have finally solved the problem. My .htaccess was completely OK; the problem was that apache use to disable directories from having an .htaccess file.

So I have wrote these lines into the httpd.conf file:

<Directory c:/myWebDirectory>
Options FollowSymLinks
AllowOverride All
</Directory>

Doing that, Apache allows "myWebDirectory" folder to have an .htaccess file.

Thanks a lot to everybody

jdMorgan

11:56 am on Oct 2, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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).

Jim

Blade_Stom

12:07 pm on Oct 2, 2009 (gmt 0)

5+ Year Member



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.

Thanks

jdMorgan

1:41 pm on Oct 2, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



No problem... I'm glad you solved the "mystery" -- I hate "mysteries"... :)

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month