我使用此重写代码将所有请求重写到.php
文件:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$ $1.php [L]
因此,当我输入index
遗嘱index.php
加载或输入contact
遗嘱contact.php
加载时。
但是当我输入一个不存在的名称时,我会收到内部服务器错误,例如我输入了这个名称,test
或者fdgdfg/ewrtt/ddfghdfg
,之后我会收到这个错误:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@mydomain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
我的也ErrorDocument 404 error.php
有.htaccess
。
这是我的完整.htaccess
文件:
ErrorDocument 404 index.php
RewriteEngine on
RewriteBase /shop
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$ $1.php [L]