htaccess的的RewriteBase [英] htaccess RewriteBase
问题描述
我有我的根两个目录:的/ dev
和 /直播
这些目录内的所有内容都如 /css/style.css
或 /js/home.js $ C $相对路径C>。
我希望能够改变使用htaccess的,这样的相对路径将成为根目录 /live/css/style.css
等或 /dev/css/style.css
根据我在使用本网站的哪个版本。
我已经尝试使用下面的code在.htaccess位于内侧的试图/直播
目录:
RewriteEngine叙述上
的RewriteBase /现场/
我也尝试过使用的RewriteBase /的public_html /生活/
。
不过,内容的路径仍然 http://domain.com/css/style.css
,而不是的http://域名。 COM /生活/ CSS / style.css中
当我查看该网站。
有没有人任何想法?
感谢你。
编辑>> 对不起,我要解释一下,我的根htaccess具有以下规则指向两个目录:
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{HTTP_HOST}!^ WWW \。域\ .COM [NC]
的RewriteCond%{HTTP_HOST} ^((WWW \)?([AZ] +)\。)域\ .COM [NC]
重写规则^((WWW \)?([AZ] +)\。)域\ .US $ /live/index.php?tag=%3 [L,P]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{HTTP_HOST}!^ WWW \。域\ .COM [NC]
的RewriteCond%{HTTP_HOST} ^开发。((WWW \)?([AZ] +)\。)域\ .COM [NC]
重写规则^((WWW \)?([AZ] +)\。)域\ .US $ /live/index.php?tag=%3 [L,P]
<一个href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase"><$c$c>RewriteBase$c$c>让您修复着如何的URL会转换为文件路径,然后再返回的问题。这不是为你使用它来做什么。使用标准的重写规则
的RewriteCond%{REQUEST_URI}!^ /直播
重写规则^(/?)(。*)/现场/ $ 2
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]
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
这篇关于htaccess的的RewriteBase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!