Angularjs 使用RESTAPI为HTML5模式编写.htaccess文件
我正试图让HTML5模式工作,通过将它添加到我的.htaccess文件中,我能够使它工作Angularjs 使用RESTAPI为HTML5模式编写.htaccess文件,angularjs,.htaccess,rest,Angularjs,.htaccess,Rest,我正试图让HTML5模式工作,通过将它添加到我的.htaccess文件中,我能够使它工作 RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^ index.html [L] 我的index.html文件与一个名为api.php的php文件位于同一文件夹中,该文件将处理后端RESTAPI 基本上,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]
我的index.html文件与一个名为api.php的php文件位于同一文件夹中,该文件将处理后端RESTAPI
基本上,我希望HTML5模式继续工作,但所有的请求,例如localhost/api/。。。发送到api.php
我尝试了几行,但它打破了HTML5模式
如果我能弄明白这一点,那就太棒了
最诚挚的问候另一个答案建议使用此配置
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]