下面是我的目录结构
localhost or livehost
-app
-bootstrap
-public
-vendor
-code
-demo
下面是我的.htaccess
Here is my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
RewriteRule ^(.*)$ public/blog/$1 [L]
</IfModule>
下面是我的路线
Route::get('/', 'Sys@Home');
Route::get('blog', 'Sys@Blog');
Route::get('contact', 'Sys@Contact');
要访问这些,我并不想进入我的网址为
To access these , I don't want to enter my url as
localhost/public/
localhost/public/blog
localhost/public/contact
相反,它足以进入为
Instead its enough to enter as
localhost
localhost/blog
localhost/contact
与此同时,它不应该适用于这些文件夹 / code
和 /演示
访问该目录。
所以我就写例外,从这个问题的.htaccess例外特定的文件夹这些目录
So I got to write exception to these directories from this question .htaccess exception to particular folders
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule %{THE_REQUEST} /code
RewriteRule %{THE_REQUEST} /temp
RewriteRule ^ - [L]
RewriteRule ^(.*)$ public/$1 [L]
RewriteRule ^(.*)$ public/blog/$1 [L]
</IfModule>
在应用此我能够访问该文件夹后本地主机/ code
和
localhost/demo
但我不能能够访问该文件夹像
But I can't able to access the folder like
localhost
localhost/blog
localhost/contact
我
如何让它既可以吗?
How can i make it both possible ?
您可以试试:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /(code|tmp) [NC]
RewriteRule ^ - [L]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
</IfModule>