【发布时间】:2015-12-12 21:55:19
【问题描述】:
我正在尝试使用 Apache mod_rewrite 来获得 SEO URL,我有以下内容:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1
RewriteRule ^([^/]*)\.php$ /index.php?a=$1 [L]
RewriteRule ^([^/]*)/([^/]*)\.php$ /index.php?a=$1&id=$2 [L]
重定向到 www 和 https 的第一部分工作正常,但我需要实现以下不起作用的 URL 重写:
-
https://www.domain.com/index.php?a=explore到https://www.domain.com/explore/ -
https://www.domain.com/index.php?a=page&b=about到https://www.domain.com/about/ -
https://www.domain.com/index.php?a=track&id=9到https://www.domain.com/track/idno -
https://www.domain.com/index.php?a=explore&filter=newtag到https://www.domain.com/explore/newtag/
【问题讨论】:
-
如果URL是
https://www.domain.com/foo/bar那你想怎么改写? -
抱歉忘记了现在修复的链接之间的to。
标签: apache .htaccess mod-rewrite url-rewriting friendly-url