我有一个laravel 5安装。工作完美。
公用文件夹中的.htaccess
是默认的,工作正常:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
在public
(root)文件夹中,我有一个名为webapp
webapp
包含我的应用内置版的网页版angularjs
,需要push states
.htaccess
文件夹中的理想webapp
将是:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# html5 pushstate (history) support:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
</ifModule>
但似乎.htaccess
文件夹中的webapp
未被触发。
我可能需要在laravel
public
文件夹中编写条件和规则。但我不知道如何处理这个以及以什么顺序等等。
有人可以帮助我将2 .htaccess
个文件合并为一个文件放在public
文件夹中。
答案 0 :(得分:0)
这对我有用:
bash-3.2$ cat .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301] #This creates a redirect loop for angular
# IF the resource does not exist as an actual directory...
RewriteCond %{REQUEST_FILENAME} !-d
# OR an actual file...
RewriteCond %{REQUEST_FILENAME} !-f
# AND is being requested from angular directory a/
# THEN send it to the angular routing file
RewriteRule ^(a/.*) /a/index.html [NC,L]
# IF the resource does not exist as an actual directory...
RewriteCond %{REQUEST_FILENAME} !-d
# OR an actual file...
RewriteCond %{REQUEST_FILENAME} !-f
# THEN send the traffic to laravel routing
RewriteRule ^ index.php [L]
</IfModule>
bash-3.2$