我想将每个url请求(不是文件或目录)映射到testindex.html
我的。htaccess包含这个:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . testindex.html
但如果我尝试
http://localhost/test/aaaaaaaa
那么我只得到404-Error。
Apache webserver已经启动,并且在test-project中存在一个testindex.html。
你的问题是path
(因为RewriteBase
)。
假设你的htaccess是在test
文件夹,如testindex.html
。将当前代码替换为
RewriteEngine On
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . testindex.html [L]
尝试:
RewriteRule ^(.*)$ testindex.html [L]