简体   繁体   English

htaccess RewriteBase

[英]htaccess RewriteBase

I have two directories in my root: /dev and /live . 我的根目录中有两个目录: /dev/live

All content inside these directories have relative paths such as /css/style.css or /js/home.js . 这些目录中的所有内容都有相对路径,例如/css/style.css/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. 我希望能够使用htaccess更改根目录,以便相对路径变为/live/css/style.css等或/dev/css/style.css具体取决于我使用的网站版本。

I have tried using the following code in .htaccess located inside the /live directory: 我尝试在位于/live目录中的.htaccess中使用以下代码:

RewriteEngine on
RewriteBase /live/

I have also tried using RewriteBase /public_html/live/ . 我也尝试过使用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. 但是,当我查看网站时,内容路径仍然是http://domain.com/css/style.css而不是http://domain.com/live/css/style.css

Has anyone any ideas? 有没有人有任何想法?

Thank you. 谢谢。

EDIT>> Sorry I should explain that my root htaccess has the following rules pointing towards the two directories: 编辑>>对不起我应该解释我的根htaccess有以下规则指向两个目录:

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]

RewriteBase lets you fix issues with how URLs get translated to file paths and back again. RewriteBase允许您修复URL如何转换为文件路径以及再次返回的问题。 It's not for what you're using it for. 这不是你用它的原因。 Use a standard RewriteRule 使用标准的RewriteRule

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM