且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

URL重写添加目录的URL开始

更新时间:2023-02-24 11:31:29

的.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