homepage Welcome to WebmasterWorld Guest from 50.17.21.7
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Server differences with slashes
Trying to set localhost and web server the same
suzie250




msg:3063313
 5:01 pm on Aug 28, 2006 (gmt 0)

This works on localhost
RewriteRule ^museum/([^/]+).html$ file-details.php?$1 [L]

This work on my website server
RewriteRule ^museum/([^/]+).html$ /file-details.php?$1 [L]

What setting do I need to change on localhost so that I do not need to change the rewrite rules before uploading the htaccess file?

 

jdMorgan




msg:3063518
 8:03 pm on Aug 28, 2006 (gmt 0)

Either should work, assuming thst your code is in the root directory of the site.

The fact that the no-slash path does not work on localhost hints at some difference in the DocumentRoot [httpd.apache.org] path configuration in httpd.conf -- possibly a trailing slash on that path.

That's the most likely cause, but examine your error log file -- Especially the logged path if a rewritten access attempt fails. By examining that path, you can often see where things went wrong in the URL-to-filepath translation process, and this will focus your question.

Also, I suspect that the regex in your rules should be "[^.]", not "[^/]". But that depends on what you're trying to match. It's also possible you might want "[^./]".

Jim

suzie250




msg:3063864
 3:04 am on Aug 29, 2006 (gmt 0)

Actually, I did not have the files in the root directory. Just one level down and I thought as long as I had the htaccess file in the same directory, I would not need to include the folder name on the right side of the rule.

This worked with the slash
RewriteRule ^museum/([^/]+).html$ /myfolder/file-details.php?$1 [L]

Am I correct that the server starts to read the
right side of the rule from the root and stops looking for the file at the first slash?

Since I have a few different websites, I thought I would be smart and have a different folder for each one under htdocs. I wasn't ready to start messing with Virtual Hosts but that's what I need to do now.

On a side note: jdmorgan, I ran across a thread the other day that is a couple of years old and you said "I'm not an expert". I smiled because you are like a god to many of us. I really appreciate the help that you give and hope someday that I will be able to contribute as much as you.

jdMorgan




msg:3063915
 4:00 am on Aug 29, 2006 (gmt 0)

> Am I correct that the server starts to read the
> right side of the rule from the root and stops looking for the file at the first slash?

I'm not sure how to interpret this, but prepending a slash on the substitution URL (on the right side) tells the server to start at the document root and use the specified path, while leaving the slash off would mean to start in the current (.htaccess) directory, and append the specified path to that. So, it should make no difference if the code is in the root Web-accessible directory, which is why I qualified my statement above.

>I really appreciate the help that you give and hope someday that I will be able to contribute as much as you.
Thank you, and so do I! (We need all the help we can get back here) :)

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