我正在尝试使用 .htaccess 使我的日历网站的 URL 看起来更好,但我无法让它工作。
我已经有一条规则,它删除了 .php 扩展名,而且效果很好。它看起来像这样:
RewriteEngine On
# turn on the mod_rewrite engine
RewriteCond %{REQUEST_FILENAME}.php -f
# IF the request filename with .php extension is a file which exists
RewriteCond %{REQUEST_URI} !/$
# AND the request is not for a directory
RewriteRule (.*) $1\.php [L]
# redirect to the php script with the requested filename
我当前的 URL 如下所示: http ://mydomain.com/calendar/calendar-site?year=2013&month=november
...我想让它看起来像这样: http: //mydomain.com/calendar/2013/November
该站点无需重写即可完美运行,我使用 $_GET[] 获取 URL 中年份和月份的值,但在重写后,它无法从 url 中获取值。
我已经尝试过这些(当然不是同时尝试):
RewriteRule ^calendar/([^/]*)$ /calendar-site.php?year=$1&month=$2 [L]
RewriteRule ^([^/]*)/([^/]*)$ /calendar-site.php?year=$1&month=$2 [L]
第一个创建 404 页面,第二个无法从 url 获取值 + 它弄乱了样式表。
希望你们能在这里帮助我:D
谢谢 - 杰斯珀