这是个很简单的问题,但我和他从来没有相处过。
以下是.htaccess:
# Disable the directory processing, Apache 2.4
DirectoryIndex disabled xxx
RewriteEngine On
# Serve existing files
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
# For / serve index.html if it exists
RewriteCond %{REQUEST_URI} ^/$
RewriteCond index.html -f
RewriteRule .? index.html [L]
# Otherwise use front controller
RewriteRule .? app.php [L]如果我注释掉了RewriteCond index.html -f行,只要index.html确实存在,它就能工作。但是我也想检查一下index.php,所以我需要文件存在检查。如果没有其他的话,我想了解为什么张贴的线路不能工作。
发布于 2015-03-28 18:35:40
这应该是可行的:
# Disable the directory processing, Apache 2.4
DirectoryIndex disabled xxx
RewriteEngine On
# Serve existing files
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# For / serve index.html if it exists
RewriteCond %{DOCUMENT_ROOT}/index.html -f [NC]
RewriteRule ^/?$ index.html [L]
# Otherwise use front controller
RewriteRule ^ app.php [L]请记住,带有-f或-d的-d需要文件或目录的完整路径,这就是为什么需要在文件名前加上%{DOCUMENT_ROOT}/的原因。没必要在这里避开点。
https://stackoverflow.com/questions/29320684
复制相似问题