URL重写添加目录的URL开始 [英] URL rewrite to add a directory at start of url
问题描述
在我的网站上,所有的图像/样式表在/ CMS / ...目录。最近,我们的网站转移到新的服务器,在那里他们引用的是/ newdirectory / CMS /...
On my website, all images/stylesheets are in the /CMS/... directory. Recently, our website shifted to new server at a temporary url where they referenced like /newdirectory/CMS/...
我们如何追加/ newdirectory /所有/ CMS /电话?
How can we append /newdirectory/ to all /CMS/ calls?
推荐答案
在的.htaccess 文件
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/newdirectory/CMS/
RewriteRule ^(.*)$ /newdirectory/CMS/$1
这将执行重写,所以访问的 http://www.server.com/CMS/index.html 的实际上将服务于的 HTTP内容://www.server。 COM / newdirectory / CMS / index.html的的
This will perform a rewrite, so accessing http://www.server.com/CMS/index.html will actually serve the content of http://www.server.com/newdirectory/CMS/index.html
注:该解决方案假定CMS是被服务这个领域的唯一的事情
Note: This solution assumes that the CMS is the only thing being served for this domain.
如果这个域比CMS在职(只有CMS应该转),那么下面可能会更好:
If this domain is serving more than the CMS (and only the CMS should be redirected), then the following may be better:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/CMS/
RewriteRule ^(.*)$ /newdirectory/$1
这篇关于URL重写添加目录的URL开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!