Htaccess rewritebase

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

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

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

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

 RewriteEngine on RewriteBase /live/ 

I also tried using RewriteBase /public_html/live/ .

But when I browse the site, the content paths are still http://domain.com/css/style.css , not http://domain.com/live/css/style.css .

Does anyone have any ideas?

Thanks.

EDIT → Sorry, I have to explain that in my root htaccess there are the following rules pointing to two directories:

 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] RewriteCond %{HTTP_HOST} ^((www\.)?([az]+)\.)domain\.com [NC] RewriteRule ^((www\.)?([az]+)\.)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\.)?([az]+)\.)domain\.com [NC] RewriteRule ^((www\.)?([az]+)\.)domain\.us$ /live/index.php?tag=%3 [L,P] 
+8
php .htaccess
source share
1 answer

RewriteBase problems with URL transitions in the file path and vice versa. This is not what you use it for. Use a standard RewriteRule

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

All Articles