我的htaccess没有删除扩展名.php

时间:2014-08-01 10:38:09

标签: php

我在一个名为env_files的文件夹中定义了三个htaccess,我还有其他.htaccess内部公共文件:

screen http://i61.tinypic.com/2r2xbps.jpg

所有htaccess代码都是正确的:

# development
DirectoryIndex index.php
#Options -Indexes
ErrorDocument 404 error404
ErrorDocument 500 error404

RewriteEngine On

# REDIRECTS FROM WWW TO NON www URL
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# AVOID URL END DOT (COOKIE PROBLEMS) mydomayin.com. 
RewriteCond %{HTTP_HOST} (.*)\.$
RewriteRule (.*) http://%1/$1 [L,R=301]

# REMOVE EXTENSION .PHP
RewriteCond %{REQUEST_FILENAME} !\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

<IfModule mod_headers.c>
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf|woff|eot|svg|ttf|flv|swf)$">
  Header set Cache-Control "public, max-age=29030400"
</FilesMatch>
</IfModule>

    ## Desactiva la firma del servidor ##
ServerSignature Off

但是我的网站没有加载没有.php扩展名的pages.php: http://calendario-online.es/calendario-laboral-2015-cordoba

如果你写&#34; .php&#34;在URL的末尾,页面加载。

为什么会这样?

3 个答案:

答案 0 :(得分:0)

试试这个:

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

答案 1 :(得分:0)

 Try with this:

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

答案 2 :(得分:0)

以下.htaccess代码可以帮助您解决问题

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