GDP*_*GDP 3 redirection 301-redirect apache-2.4
之前问了一个又长又复杂的问题,现在我这里有一些代码RedirectPermanent
需要帮助。
我们正在将旧站点合并到新站点中,并且不关心将所有古老的 url 映射到新站点上的任何位置,因此所有这些都应该永久重定向到一个特殊的 index.php,它将决定是否/在哪里使用 php 进行重定向。
一个子域是例外,它应该执行相同的操作,但针对不同的index.php。
这是我试图完成的“伪配置” - 轻微的变化会起作用,但我无法让它忽略请求的完整路径,并无条件地使用查询字符串转到我选择的index.php。
#Subdomain from old site:
#Process querystring from root\oldsite\subdomain\index.php
<VirtualHost *:80>
ServerName subdomain.oldsite.com
RedirectPermanent / http://www.newsite.com/oldsite/subdomain/index.php
</VirtualHost>
#ALL other requests of any kind regardless of path
#Process querystring from root\oldsite\index.php
# Must show www.newsite.com, NOT www.oldsite.com
<VirtualHost *:80>
ServerName oldsite.com
ServerAlias www.oldsite.com
RedirectPermanent / http://www.newsite.com/oldsite/index.php
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
DNS 已设置,以便旧站点中的所有内容都转到此服务器,这些是配置文件中的第一个 VirtualHost 条目。我如何修改此代码以转到给定的index.php,无论路径如何。
www.oldsite.com ==> www.newsite.com\oldsite\index.php
www.oldsite.com/forum/anything/else ==> www.newsite.com\oldsite\index.php
www.oldsite.com/faq/category/chosen ==> www.newsite.com\oldsite\index.php
www.oldsite.com/about/us/index.php ==> www.newsite.com\oldsite\index.php
subdomain.oldsite.com/anthing ==> www.newsite.com\oldsite\subdomain\index.php
Run Code Online (Sandbox Code Playgroud)
重定向不是您所寻求的正确用途。重定向将“全部”和“附加全部”重定向到目的地,但您想要一个最终的单一目的地,所以..改用它:
RedirectMatch ^ http://newsite.example.com/oldsite/subdomain/index.php
Run Code Online (Sandbox Code Playgroud)
这会将所有内容重定向到您指定的目的地,而不附加任何其他内容。
归档时间: |
|
查看次数: |
7835 次 |
最近记录: |