我认为你不理解mod_rewrite是如何工作的。
您在此规则
RewriteRule ^photo-album-detail/(.+) photo-album-detail/?album=$1 [L]
匹配对URL是这种类型的URL http://example.com/photo-album-detail/jan-2016
的,因为这是你的匹配与模式。
如果您想要使用此类型的URL重定向http://example.com/photo-album-detail/?album=jan-2016
那么您需要匹配query string
或the request
。
这些是您需要的组合规则。
RewriteEngine On
#if request is a real file or directory do nothing
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule^- [L]
#redirect the old query string URL to the rewritten URL
RewriteCond %{THE_REQUEST} ^GET\ /photo-album-detail/\?album=([^&\s]+)
RewriteRule^/photo-album-detail/%1? [R=302,L]
#internally rewrite pretty URL to querystring
RewriteRule ^photo-album-detail/(.+) /photo-album-detail/?album=$1 [L]
让我知道这是如何适用于你。
这似乎没有做任何事情:/ – Kazehaya
你可以尝试更新的规则,看看它是否有帮助吗? – vard
这是链接到的网址:http://example.com/photo-album-detail/?album=jan-2016它应该更改为http://example.com/photo-album-detail/jan-2016对?仍然没有工作:( – Kazehaya