301 从查询字符串重定向到简单 URL

发布于 2024-11-30 01:27:09 字数 615 浏览 1 评论 0原文

我已经仔细浏览了“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦幻的味道 2024-12-07 01:27:09

尝试一下。您需要做的就是检查是否位于 X 页面,然后重定向到 Y 页面。将 RewriteCond 语句视为“if”语句。如果您需要更多重定向,只需复制最后两行并编辑路径。

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.domain\.com\/?pid=22$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/contact [L,R=301]

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.

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.domain\.com\/?pid=22$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/contact [L,R=301]
地狱即天堂 2024-12-07 01:27:09

您必须检查查询字符串中“pid”变量中的值,然后如果该变量中的值与您要重定向的页面匹配,则进行重定向。您可以使用“RewriteCond”和“RewriteRule”指令来执行此操作,如下所示:

RewriteEngine On
RewriteBase /

# Redirect pid=22 to http://www.domain.com/contact
RewriteCond %{QUERY_STRING} ^pid=22$
RewriteRule ^(.*)$ http://www.domain.com/contact [R=301,L]

您可以重复“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:

RewriteEngine On
RewriteBase /

# Redirect pid=22 to http://www.domain.com/contact
RewriteCond %{QUERY_STRING} ^pid=22$
RewriteRule ^(.*)$ http://www.domain.com/contact [R=301,L]

You can repeat the "RewriteCond" and "RewriteRule" directives to create additional redirects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文