问题描述
在一个共享服务器,我不得不从的cPanel这是越野车,消耗了大量的时间管理域的文档根目录。所以我重定向所有域一个目录可以说根
。举个例子:
On a shared server I am forced to manage document roots of domains from cpanel which is buggy and consumes lots of time. So I redirected all domains to one directory lets say root
. An example:
sd1.domain.com ---> public_html/web/
sd2.domain.com ---> public_html/web/
sd1.domain2.com ---> public_html/web/
sd2.domain2.com ---> public_html/web/
当用户浏览这些网站,我转发使用htaccess的规则,这个网站如
When user browses these websites, I forward this websites using htaccess rules such as
RewriteCond %{HTTP_HOST} ^sd1.(domain1|domain2).com [NC]
RewriteCond %{REQUEST_URI} !^/sd1/.*
RewriteRule ^(.*) sd1/$1 [L]
现在这样做将请求转发到不同的文件夹,但后来所有的URL都 SD1
附着在最后一部分
Now this does forward the request to different folder but afterwards all the url have sd1
attached on the last part
下面是一个例子
sd1.domain.com ---> sd1.domain.com #Works correctly
sd1.domain.com/page1.html ---> sd1.domain.com/sd1/page1.html # See the word sd1 on the middle
如何删除的网址??
How to remove the folder portion from the url??
推荐答案
如果我正确地理解你的问题,你应该能够使用标志PT(通过模式),这将导致重写目标做它被传递回URL映射引擎:
if I understand your question correctly, you should be able to do it by using the flag PT (Passthru), which causes the rewrite target to be passed back to the URL mapping engine:
RewriteCond %{HTTP_HOST} ^sd1.(domain1|domain2).com [NC]
RewriteCond %{REQUEST_URI} !^/sd1/.*
RewriteRule ^(.*) sd1/$1 [PT,L]
希望它帮助。
Hope it helps.
这篇关于如何从URL转发到sudirectory时删除子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!