我正在尝试为SEO目的重写URL。
旧网址为:
http://www.example.com/recipe_local.php?hl_cusine=1
如果用户来到url
,新网址应该像下面那样并自动重定向到此网址http://www.example.com/recipes/healthy-recipes
.htaccess中的我的代码是:
RewriteEngine on
RewriteRule ^recipes/healthy-recipes/$ recipe_local.php?hl_cusine=$1 [NC,L]
RewriteRule ^recipes/healthy-recipes$ recipe_local.php?hl_cusine=$1 [NC,L]
即使经过数小时的研究,我也不知道为什么这不起作用:(
答案 0 :(得分:1)
重写中的$1
指向您从未捕获的反向引用
除非你有RewriteCond
,否则你没有出示?
试试:
RewriteEngine on
RewriteRule ^recipes/healthy-recipes/$ recipe_local.php?hl_cusine=1 [NC,L]
RewriteRule ^recipes/healthy-recipes$ recipe_local.php?hl_cusine=1 [NC,L]