Mod rewrite 如何设置Apache mod_rewrite以重定向除一个子文件夹外的所有子文件夹
我刚刚创建了一个新网站,准备从我当前的Web服务器切换到新的Web服务器 当前Web服务器将重命名为www2 新的Web服务器将被称为www 我想将所有流量从www2重定向到www,除了一个目录。我的目录结构如下所示:Mod rewrite 如何设置Apache mod_rewrite以重定向除一个子文件夹外的所有子文件夹,mod-rewrite,redirect,webserver,apache,Mod Rewrite,Redirect,Webserver,Apache,我刚刚创建了一个新网站,准备从我当前的Web服务器切换到新的Web服务器 当前Web服务器将重命名为www2 新的Web服务器将被称为www 我想将所有流量从www2重定向到www,除了一个目录。我的目录结构如下所示: /var /www /html index.html page2.html /orange index.html ...
/var
/www
/html
index.html
page2.html
/orange
index.html
...
/archive
index.html
important-page1.html
important-page2.html
/turquoise
index.html
...
我想将所有内容重定向到相应的www页面
e.g. www2.mydomain.com/orange/index.html -> www.mydomain.com/orange/index.html
www2.mydomain.com/turquoise/index.html -> www.mydomain.com/turquoise/index.html
除了/archive文件夹。我希望用户请求:
www2.mydomain.com/archive/important-page1.html以查看ww2上的页面,并且不会被重定向
我使用mod_重写还是mod_重定向?我可以在httpd.conf中设置它吗
谢谢是的,您需要重新编写mod_。 尝试: 注意:R=301中的301是一个,如果希望它是临时的,则需要将其更改为302 在www2.mydomain.com的httpd.conf或httpd.conf.d文件中的VirtualHost配置中添加:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/archive.*
RewriteRule ^(.*)$ http://www.mydomain.com$1
>>我使用mod_重写还是mod_重定向?取决于您是想重定向还是只是重写。
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/archive.*
RewriteRule ^(.*)$ http://www.mydomain.com$1