我阅读了所有其他类似的问题,但是不知道如何设置它,所以我的旧页面重定向到了应该的位置.
I read all the other similar questions, but could not understand how to set it up so my old pages redirect where they should.
这是我的设置:
我的旧站点页面:
www.oldsite/blog/?p=1234 www.oldsite/blog/?p=432 www.oldsite/blog/?p=xxxx
www.oldsite/blog/?p=1234 www.oldsite/blog/?p=432 www.oldsite/blog/?p=xxxx
我想像这样重定向前两个:
I would like to redirect the first two like so:
www.oldsite/blog/?p=1234-> www.newsite/somewhere/on/mysite/ www.oldsite/blog/?p=432 -> www.newsite/somewhere/else/on/mysite/
www.oldsite/blog/?p=1234 -> www.newsite/somewhere/on/mysite/ www.oldsite/blog/?p=432 -> www.newsite/somewhere/else/on/mysite/
,然后将所有其他页面(123、321、567、999等)重定向到我的主页,如下所示: www.oldsite/blog/?p= * **** -> www.newsite/
and have all other pages (123, 321, 567, 999, ...) redirect to my home page like so: www.oldsite/blog/?p=***** -> www.newsite/
提前谢谢!
推荐答案我尝试了@Jon Lin代码,但不适用于我的WordPress网站.我认为问题是我正在运行WordPress ...我应该包含我的.htaccess代码,但我不认为WP会成为问题...
I tried @Jon Lin code, but it did not work for my WordPress site. I think the problem was that I am running WordPress... I should have included my .htaccess code, but I was not thinking that WP would be the problem...
这是我要使其正常工作所要做的: 因为它是WP站点,所以您需要将代码放在WP mod_rewrite中.这是重定向之前我的.htaccess文件:
Here is what I had to do in order to make it work: Because it is WP site you need to put the code in the WP mod_rewrite. Here is my .htaccess before the redirects:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>及之后:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/blog/$ RewriteCond %{QUERY_STRING} ^p=998$ RewriteRule . /some/where/over-there? [L,R=301] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>希望这将帮助其他运行WP并遇到相同问题的人!
Hope this will help other people running WP and having the same problem!
更多推荐
.htaccess和301重定向(动态页面)wordpress
发布评论