Kit
Kit

Reputation: 4105

htaccess RewriteBase

I have two directories in my root: /dev and /live.

All content inside these directories have relative paths such as /css/style.css or /js/home.js.

I want to be able change the root directory using htaccess so that the relative paths would become /live/css/style.css etc or /dev/css/style.css depending on which version of the site I was using.

I have tried using the following code in .htaccess located inside the /live directory:

RewriteEngine on
RewriteBase /live/

I have also tried using RewriteBase /public_html/live/.

But, the content paths are still http://domain.com/css/style.css rather than http://domain.com/live/css/style.css when I view the site.

Has anyone any ideas?

Thank you.

EDIT>> Sorry I should explain that my root htaccess has the following rules pointing towards the two directories:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST} ^((www\.)?([a-z]+)\.)domain\.com [NC]
RewriteRule ^((www\.)?([a-z]+)\.)domain\.us$ /live/index.php?tag=%3 [L,P]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST} ^dev.((www\.)?([a-z]+)\.)domain\.com [NC]
RewriteRule ^((www\.)?([a-z]+)\.)domain\.us$ /live/index.php?tag=%3 [L,P]

Upvotes: 8

Views: 40663

Answers (1)

outis
outis

Reputation: 77400

RewriteBase lets you fix issues with how URLs get translated to file paths and back again. It's not for what you're using it for. Use a standard RewriteRule

RewriteCond %{REQUEST_URI} !^/live
RewriteRule ^(/?)(.*) /live/$2

Upvotes: 10

Related Questions