我有一个URL重写,删除文件扩展名。它使用.html
页面,但它给了我一个“404页面未找到”的错误.php
文件。URL重写工作.html但不是.php
这里是我的全.htaccess
文件
# The following will allow you to use URLs such as the following:
#
# example.com/anything
# example.com/anything/
#
# Which will actually serve files such as the following:
#
# example.com/anything.html
# example.com/anything.php
#
# But *only if they exist*, otherwise it will report the usual 404 error.
Options +FollowSymLinks
RewriteEngine On
rewritecond %{HTTP_HOST} ^inaflashgraphics.com$
rewriterule^"http\:\/\/www\.inaflashgraphics\.com\/" [R=301,L] #4e2f2fa615667
# Remove trailing slashes.
# e.g. example.com/foo/ will redirect to example.com/foo
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=permanent,QSA]
# Redirect to HTML if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
# Redirect to PHP if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
我到底做错了什么?
我建议添加一个RewriteLog并将RewriteLogLevel设置为5,这样您可以逐步查看它正在做什么。 – GarethL
不知道该怎么做 – jardane
在“RewriteEngine On”之后,在单独的行上添加以下内容:“RewriteLog/path/to/your/new/log”和“RewriteLogLevel 5”。这将在您指定的路径中创建一个日志文件,并且会在尝试确定要提供的正确文件时写入重写引擎所做的每一个步骤。很明显,当你解决问题的时候记得去掉这个! – GarethL