我正试图为SEO目的重写URL。
旧的URL是:
http://www.example.com/recipe_local.php?hl_cusine=1
新的URL应该如下所示,如果用户超过URL ,则自动重定向到此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]
即使经过数小时的研究,我也不知道为什么这不起作用:(
重写中的$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]