.htaccess和301重定向(动态页面)wordpress

编程入门 行业动态 更新时间:2024-10-27 08:34:36
本文介绍了.htaccess和301重定向(动态页面)wordpress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我阅读了所有其他类似的问题,但是不知道如何设置它,所以我的旧页面重定向到了应该的位置.

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

本文发布于:2023-10-31 18:29:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546913.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   页面   动态   htaccess   wordpress

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!