我想重写以下网址:
product_reviews.php?products_id=3
到
haendlerbewertung::_::3.html
在我的.htacces中我定义了:
RewriteRule ^haendlerbewertung::_::([^/]*)\.html$ product_reviews.php?products_id=$1 [L]
此重写规则可以正常工作,但是没有从旧URL到新URL的重定向,因此可以使用2个不同的URL调用每个站点。如果我写[L,R = 301],新的URL将被重定向到旧的,但那是错的。应将旧网址重定向到新网址。那么错误或缺失了什么?
答案 0 :(得分:0)
您可以使用以下内容:
RewriteEngine on
#redirect old url to the new one
RewriteCond %{THE_REQUEST} /product_reviews.php\?products_id=([^\s]+) [NC]
RewriteRule ^.+$ /haendlerbewertung::_::%1.html? [NE,L,R]
# map new url to the old one
RewriteRule ^haendlerbewertung::_::([^/]*)\.html$ /product_reviews.php?products_id=$1 [L]