301 从查询字符串重定向到简单 URL
我已经仔细浏览了“301 重定向”搜索结果的前十页,但找不到答案,所以这里...
我已经从一个蹩脚的旧 CMS 迁移过来,它没有给我的页面带来很好的效果我想为我的关键页面设置 301 重定向。
当前网址:http://www.domain.com/?pid=22 新 URL:http://www.domain.com/contact/
我正在使用 Wordpress 和我的当前的 htaccess 文件如下所示:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
任何帮助都会很棒!
I've had a good look through the first ten pages of search results for "301 redirects" and can't find the answer so here goes...
I've moved from a crappy old CMS that didn't give my pages nice URLs to one that does and I want to set up a 301 redirect for my key pages.
Current URL: http://www.domain.com/?pid=22
New URL: http://www.domain.com/contact/
I'm using Wordpress and my current htaccess file looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any help would be awesome!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下。您需要做的就是检查是否位于 X 页面,然后重定向到 Y 页面。将 RewriteCond 语句视为“if”语句。如果您需要更多重定向,只需复制最后两行并编辑路径。
Give this a try. All you need to do is check to see if you are on page X and then redirect to page Y. Consider RewriteCond statements to be 'if' statements. If you need more redirects just duplicate the last two lines and edit the paths.
您必须检查查询字符串中“pid”变量中的值,然后如果该变量中的值与您要重定向的页面匹配,则进行重定向。您可以使用“RewriteCond”和“RewriteRule”指令来执行此操作,如下所示:
您可以重复“RewriteCond”和“RewriteRule”指令来创建其他重定向。
You have to check the query string for the value in the "pid" variable and then redirect if the value in that variable matches a page you want to redirect. You can do this with the "RewriteCond" and "RewriteRule" directives like this:
You can repeat the "RewriteCond" and "RewriteRule" directives to create additional redirects.