我希望我的网站在我的index.html点不管URL是什么。 http://localhost/WebsiteName/ http://localhost/WebsiteName/whatever http://localhost/WebsiteName/whatever/whatever-1/whatever-2/whatever-3/etc
在我的Apache配置使用此重写代码:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.html [L]
我的URL正常工作时,URL是任何这些: http://localhost/WebsiteName/ http://localhost/WebsiteName/whatever
但是,当它是破裂这样或进一步扩展: http://localhost/WebsiteName/whatever/ http://localhost/WebsiteName/whatever/whatever-1/whatever-2/whatever-3/etc
它充当如果有另一个文件夹中“无所谓”的目录中,每当我用破的其中一个网址。
我不想要的网址改变,我只是希望它在我的index.html指出,无论它是什么。
根据关你有什么在那里,所有这些网址的应该去您的index.html。中的index.html被认为是在DOCUMENT_ROOT。
我不知道你的问题是,但是,也许,而不必重写非文件的条件是什么。停止重写时,它的一个文件。我注意到在我的网站的任何变化,无论是配置,但也许它可以为你工作。
RewriteEngine on
### If a uri leads to an actual file or directory (presumably with it's own index.html), then don't rewrite any further
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
### everything else
RewriteRule . /index.html [L]