我想重写一些网址
http://www.domain.com/products/feed.php?keywords=*somewords*=>
http://subdomain.domain.com/products/feed/*somewords*我已经设置了htaccess
RewriteRule 301 products/feed.php?keywords=(.*?) http://subdomain.domain.com/products/feed/$2.xml但它似乎不起作用,怎么写才是对的?谢谢。
发布于 2015-01-31 13:10:16
您可以在DOCUMENT_ROOT/.htaccess文件中使用以下代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain].com$ [NC]
RewriteCond %{THE_REQUEST} \s/+(products/feed)\.php\?keywords=([^\s&]+) [NC]
RewriteRule ^ http://subdomain.domain.com/%1/%2? [R=302,L,NE]您还需要在子域的根.htaccess中使用此规则:
RewriteEngine On
RewriteBase /
RewriteRule ^(products/feed)/([^/.]+)/?$ $1.php?keywords=$1 [L,QSA,NC]发布于 2015-01-31 13:09:12
您可以使用这个.htaccess
RewriteEngine on
RewriteCond %{QUERY_STRING} keywords=([^&]+) [NC]
RewriteRule ^products/feed\.php$ http://subdomain.domain.com/products/feed/%1 [NC,NE,L,R=301]https://stackoverflow.com/questions/28251900
复制相似问题