且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

动力301重定向

更新时间:2022-10-15 08:36:05

试试这个:

 的RewriteCond%{QUERY_STRING} Q =([0-9] +)$
重写规则^(。*)/ $ 1?p值= 1%[L,R = 301]
 

您将需要的RewriteCond 作为阿帕奇不允许对匹配的查询字符串重写规则

修改

 的RewriteCond%{REQUEST_URI} ^ /领导能力/细节/ $
的RewriteCond%{QUERY_STRING} Q =([0-9] +)$
重写规则^(。*)/ $ 1?p值= 1%[L,R = 301]
 

We made a mistake in the scope of our dynamic pages on a new site, and have some incorrect pages already spidered in Google.

I need to redirect the following format: http://www.domain.com/dir/dir/?q=120

To this format: http://www.domain.com/dir/dir/?p=120

Only difference is the 'q' needs to be a 'p'.

RewriteEngine is on, as I've already consolidated traffic from domain.com to www.domain.com

This is what I have in my root .htaccess file:

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^centerline.com [NC] 
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301] 
RewriteRule ^(/leadership/detail/)\?q=([0-9]+)$    $1?p=$2 [R=301, L]

Try this:

RewriteCond %{QUERY_STRING} q=([0-9]+)$
RewriteRule ^(.*)$ /$1?p=%1 [L,R=301]

You'll need the RewriteCond as apache doesn't allow matching against the querystring in a RewriteRule

EDIT

RewriteCond %{REQUEST_URI} ^/leadership/detail/$
RewriteCond %{QUERY_STRING} q=([0-9]+)$ 
RewriteRule ^(.*)$ /$1?p=%1 [L,R=301]