【发布时间】:2015-05-11 06:34:32
【问题描述】:
在这篇文章中:htaccess add .html extension for urls with or without trailing slash 我得到了 99% 的将 slug 重写为 .html 扩展名的解决方案。
我的问题是,是否也可以使
http://domain.com
动态的?
index.php 可能会或可能不会在子目录(IE.test/index.php)上运行。
提到的帖子上的代码是:
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-l
RewriteRule ^(([\w/-]+)?[\w-])/?(?!:\.html)$ http://domain.com/$1.html [L,R=301]
RewriteRule ^(([\w/-]+)?[\w-])\.html$ test/index.php?slug=$1 [L]
PS:%{HTTP_HOST} 似乎无法解决问题。
【问题讨论】:
标签: .htaccess