Welcome to WebmasterWorld Guest from 54.205.209.95

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

RewriteRule Problem

Please help

   
7:55 pm on Dec 21, 2002 (gmt 0)

10+ Year Member



I have been working on this part of my .htaccess file all day. It should be simple, but just won't work:
RewriteBase /
RewriteCond %{HTTP_HOST} ^widgetsupply\.com [NC]
RewriteRule ^/(.*) /widgetsupply/ [L]

I am trying to rewrite all requests for [widgetsupply.com...] to the widgetsupply/ directory. My other domain (widgetssupply.com) uses the root directory, but I need them to share pictures and databases.

With the code above it pulls the files from the root directory. If I take out some of the slashes I get unspeakable errors.

TIA,
Kevin

3:21 pm on Dec 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I correctly understand what you're trying to do, you're pretty close!

I think amending your rule to:


RewriteRule ^(.*) http://widgetsupply.com/widgetsupply/$1 [L]
will accomplish what you're after.

Hopefully, the true experts will refine this a bit for us if necessary.

3:37 am on Dec 23, 2002 (gmt 0)

10+ Year Member



I have tried that too. I get a forbidden message:
Forbidden
You don't have permission to access /widgetsupply/widgetsupply/widgetsupply/...yougetthepicture.../widgetsupply/widgetsupply/ on this server.
4:01 am on Dec 23, 2002 (gmt 0)

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



iJeep,
You're having a recursion problem.

Use another RewriteCond to make sure that the rule will not be applied to anything but requests for the domain, and not for subdirectories.

Something like this might work:


RewriteCond %{HTTP_HOST} ^widgetsupply\.com [NC]
RewriteCond %{REQUEST_URI} !/widgetsupply/ [NC]
RewriteRule ^(.*) /widgetsupply/$1 [L]

Jim
4:33 am on Dec 23, 2002 (gmt 0)

10+ Year Member



THANK YOU JIM!

You just made the (website)world a better place! ;-)

5:00 am on Dec 23, 2002 (gmt 0)

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



iJeep,

Glad it helped!

Jim