homepage Welcome to WebmasterWorld Guest from 54.197.183.230
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Virtual Host and RewriteRule
rewriterule
Blade_Stom

5+ Year Member



 
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&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

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



 
Msg#: 3999507 posted 2:17 am on Oct 2, 2009 (gmt 0)

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

5+ Year Member



 
Msg#: 3999507 posted 7:33 am on Oct 2, 2009 (gmt 0)

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

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

Blade_Stom

5+ Year Member



 
Msg#: 3999507 posted 7:41 am on Oct 2, 2009 (gmt 0)

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

jd01

WebmasterWorld Senior Member 5+ Year Member



 
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&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

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



 
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.

Jim

Blade_Stom

5+ Year Member



 
Msg#: 3999507 posted 11:42 am on Oct 2, 2009 (gmt 0)

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

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



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

Jim

Blade_Stom

5+ Year Member



 
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.

Thanks

jdMorgan

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



 
Msg#: 3999507 posted 1:41 pm on Oct 2, 2009 (gmt 0)

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

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved