Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess RewriteBase

Tags:

php

.htaccess

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]
like image 389
Kit Avatar asked Jan 30 '11 16:01

Kit


1 Answers

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
like image 171
outis Avatar answered Nov 13 '22 17:11

outis