我正在努力使html5mode工作,通过将它添加到我的.htaccess文件中,我能够使它工作。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]在与我的index.html文件相同的文件夹中,我有一个名为index.html的php文件,它将处理后端REST。
基本上,我希望html5mode继续工作,但所有的请求,例如localhost/api/ .被发送到api.php
我试了几行,但它破坏了html5mode。
如果我能想出办法的话那就太棒了。
诚挚的问候
发布于 2015-02-10 04:47:02
这个配置是在另一个答案上建议的。
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/api.php
# otherwise forward it to index.html
RewriteRule ^.*$ - [NC,L]
RewriteRule ^. /index.html [NC,L]https://stackoverflow.com/questions/28423925
复制相似问题