【发布时间】:2014-09-02 22:53:33
【问题描述】:
我已更新我的 .htaccess 文件以从 url 字符串中删除 .php 扩展名。代码在这里:
ErrorDocument 404 /lost.php
RewriteEngine On
RewriteBase /
# remove enter code here.php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
一切正常,并且正在删除 .php。唯一的问题是,当我尝试访问网站的某个区域(客户区)时,页面根本无法正常显示。截图如下:
在将上述代码添加到 .htaccess 文件之前,url 为:
www.mysite.co.uk/client-area.php
将上述代码添加到.htaccess文件后,url为:
www.mysite.co.uk/client-area/
页面没有正确显示?知道为什么会发生这种情况以及需要对 .htaccess 文件代码做些什么来解决这个问题吗?欢迎任何帮助:)
【问题讨论】: