【发布时间】:2016-01-03 08:06:54
【问题描述】:
我看到很多类似的问题,但到目前为止没有一个对我有帮助:
我在 /song/song.php?url=lang/params 下有我的脚本逻辑(对 seo 不友好的 URL)。我使用这种重写来获得一个友好的 URL,并从对 seo 不友好的 URL 加载内容,使用参数来区分语言:
RewriteRule ^songs-and-chords/(.*?)(/*)?$ /song/song.php?url=en/$1 [NC,L]
RewriteRule ^canzoni-e-accordi/(.*?)(/*)?$ /song/song.php?url=it/$1 [NC,L]
现在我想阻止访问 /song/song.php,强制重定向到对 seo 友好的,所以像这样,使用 %{THE_REQUEST} 进行外部重定向:
RewriteCond %{THE_REQUEST} .*?song/song\.php\?url=it/(\S*) [NC]
RewriteRule /canzoni-e-accordi/$1 [R,L]
RewriteCond %{THE_REQUEST} .*?song/song\.php\?url=en/(\S*) [NC]
RewriteRule /songs-and-chords/$1 [R,L]
RewriteCond %{THE_REQUEST} ^.*?song/song\.php.*$ [NC]
RewriteRule /songs-and-chords/ [R,L]
但是没有执行此规则...我做错了什么?我怎样才能以一种好的方式调试它?
(我已经在 song.php 脚本中使用了 rel="canonical" 但我仍然希望该脚本根本无法访问)。
【问题讨论】:
标签: .htaccess mod-rewrite url-redirection friendly-url