.htaccess规则允许使用干净的URL和index.php

时间:2015-09-20 12:05:13

标签: apache .htaccess mod-rewrite model-view-controller

我有一个项目配置设置干净的URL(意思是没有文件扩展名)。现在,我正在尝试在我的项目中为博客配置CMS,这是一个MVC框架,因此它的路径中包含index.php。平台的配置文档提供了一个重写规则来禁用index.php并拥有干净的URL,但不知何故,它们的规则与我当前的设置冲突。

我目前的重写规则如下:

RewriteEngine On
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

博客平台的文档说,设置如下:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

我正在寻找合法的网站,我的网站上没有文件扩展名的网址,以及根据文档对博客平台的正确配置。

正在使用的博客平台是Anchor CMS

0 个答案:

没有答案