重写无法捕获简单错误

时间:2009-01-22 11:45:54

标签: apache .htaccess mod-rewrite

最近我添加了这个文件的尾部来优化url,比如site / 5 / john-doe [.php]而不是site / 5 / john-doe / [index.php],但是,我更喜欢我的自定义错误文档,这些修改称为黑色&白色“内部服务器错误”和“附加404”错误页面。知道大多数站点将保持旧的面向目录的格式并且必须与新的面向文件的系统共存可能会有所帮助。谢谢你的帮助。

<Files .htaccess>
order allow,deny
deny from all
</Files>

Options -Indexes

ErrorDocument 403 /errors/forbidden.php
ErrorDocument 404 /errors/notfound.php

#AddType 'text/html; charset=UTF-8' html php

# If you want Apache to use index.rhtml in addition to index.php etc.
DirectoryIndex index.rhtml index.php index.html index.htm

AddHandler rubypage .rhtml
Action rubypage /scripts/erb.cgi

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ $1.php [L,QSA]

1 个答案:

答案 0 :(得分:1)

试试这个:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !\.php$ %{REQUEST_URI}.php [L,QSA]
相关问题