我有一个在CakePHP 2.6上运行的AngularJS应用程序。我想在Angular中启用html5mode
,所以我不必在URL中包含#
,但这样做需要配置一些.htaccess文件,以便所有请求都能访问index.html。.htaccess和CakePHP:创建一个用于Angular-UI路由器的目录
并非所有我的web应用的是角,所以我不能只是重定向一切而不是index.html-,我想设置的东西,所以所有的请求一定子目录(及其子目录)重定向到该子目录的index.html
。
CakePHP有一个文件夹结构是这样的:
/ // Server web root directory: index.php, etc
----/app // The directory containing the actual Cake app
----/webroot // Web assets used by the Cake app
----/myapp // Where I'd like to store the index.html for my Angular app
我希望得到这个设置,以便于/myapp
或其子目录中的任何要求都会自动重定向到/app/webroot/index.html
。有没有人有关于如何去做这件事的任何想法?
我现在的.htaccess文件:
/:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/应用:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/应用程序/ webroot的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/(app/webroot/)?(img|css|js|eot)/(.*)$
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>