[英].htaccess 301 redirect Apache
I am really having trouble with this Rewrite Rule 我真的很难使用此重写规则
RewriteRule ^index.php?a=profile&u=(.*)$ /profile/$1 [R=301]
I want to make 301 redirect like mysite.com/profile/USERNAME
我想像mysite.com/profile/USERNAME
一样进行301重定向
Querystring is not part of match in RewriteRule, you need to match against %{THE_REQUEST}
var in RewriteCond
and then use %n
to get that match : Querystring不是RewriteRule中match的一部分,您需要在RewriteCond
中与%{THE_REQUEST}
var进行匹配,然后使用%n
获得该匹配:
This should be your complete htaccess : 这应该是您完整的htaccess:
RewriteEngine on
RewriteCond %{THE_REQUEST} /index\.php\?a=profile&u=([^\s]+) [NC]
RewriteRule ^ /profile/%1? [L,R]
RewriteRule ^profile/([^/]+)/?$ /index.php?a=profile&u=$1 [NC,L]
Try 尝试
RewriteCond %{QUERY_STRING} ^a=profile&u=(.*)$
RewriteRule ^index.php /profile/%1 [L,R]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.