我在这个.htaccess文件中做错了什么?

时间:2015-02-09 23:52:26

标签: php apache .htaccess

我正在尝试使用Apache .htaccess文件在我的网站上设置干净的URL。下面的代码允许我从任何文件名中删除.php,它从example.com重定向到www.example.com。但是第一条规则并没有按照我的意图行事。它应该将example.com/s/$_GET [的']视为example.com/index?s=$_GET [的'](就像我的意思是说,如果你去了类似.example.com / s / blue-hat-5,您将获得与example.com/index?s-blue-hat-5相同的页面,但它会返回404错误。我知道这是我已经错过的一种愚蠢的东西,但现在已经杀了我好几天了。有什么提示吗?

Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^s/([a-zA-Z0-9\-]+)/?$ /index.php?m=$1 [L,QSA]

Options -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC]

0 个答案:

没有答案