Welcome to WebmasterWorld Guest from 54.198.93.179

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Server differences with slashes

Trying to set localhost and web server the same

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

5+ Year Member



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?

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

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



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

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

5+ Year Member



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.

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

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



> 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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month