【发布时间】:2016-05-22 15:04:13
【问题描述】:
我遇到了一个问题,我的 htaccess 重写命令在本地主机上运行,但在上传到服务器时它们部分运行。
Options +FollowSymLinks
Options -Multiviews
#Turn Rewrite Engine on
RewriteEngine on
#rewrite for pages
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteRule ^about about.php [NC,L]
RewriteRule ^archive archive.php [NC,L]
RewriteRule ^privacy privacy.php [NC,L]
RewriteRule ^terms terms.php [NC,L]
RewriteRule ^contact contact.php [NC,L]
RewriteRule ^submit submit.php [NC,L]
RewriteRule ^article/([0-9]+)/([0-9a-zA-Z_-]+) article.php?article_id=$1&title=$2 [NC,L]
以下所有单数重写规则在本地主机和服务器上都可以正常工作:
RewriteRule ^about about.php [NC,L]
RewriteRule ^archive archive.php [NC,L]
RewriteRule ^privacy privacy.php [NC,L]
RewriteRule ^terms terms.php [NC,L]
RewriteRule ^contact contact.php [NC,L]
RewriteRule ^submit submit.php [NC,L]
当我尝试使用 url 查询字符串重写规则时,它似乎无法在服务器上运行,但在 localhost 中运行良好:
RewriteRule ^article/([0-9]+)/([0-9a-zA-Z_-]+) article.php?article_id=$1&title=$2 [NC,L]
我试图通过仅查询 id 来使其工作,但无济于事:
RewriteRule ^article/([0-9]+) article.php?article_id=$1 [NC,L]
我正在寻找的最终结果是 www.website.com/article/123/article-title
【问题讨论】:
标签: .htaccess mod-rewrite url-rewriting