2013-10-02 53 views
0

我在这里看到了一些解决方案,但他们没有帮助我。 我的index.php在这里:http://localhost/basic-2/web/index.php我无法隐藏我的重定向URL中的子文件夹.htaccess

我想指出的是,如果我输入http://localhost/basic-2,浏览器会将我重定向到http://localhost/basic-2/web/index.php的路径,但在浏览器中的URL是http://localhost/basic-2/index.php地址。 所以我想从URL中删除(或隐藏)web子文件夹。

我看到这里的许多解决方案...但没有什么:(,现在我有这个:

Options +FollowSymLinks -MultiViews 
RewriteEngine On 
RewriteCond %{DOCUMENT_ROOT}/web/$1 -f [NC] 
RewriteRule ^([^/]+)$ /web/$1 [P,L,QSA] 

但这只是列出文件夹和文件......而不是让重定向到子文件夹。

这可以重定向,但丝毫不掩饰从URL中web文件夹。

RewriteEngine On 
RewriteRule ^$ web [L] 

EDIT1 我发现另一条规则:

RewriteEngine On 
RewriteRule ^$ web/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ web/$1 

这可以重定向!但是,这条规则不隐藏(或删除)web文件夹仍然...

+0

凡有这些规则?在'basic-2'文件夹中? –

+0

是的,规则(.htaccess)在'basic-2'文件夹中:) –

回答

0

尝试类似:

Options +FollowSymLinks -MultiViews 
RewriteEngine On 
RewriteBase /basic-2/ 

RewriteCond %{DOCUMENT_ROOT}/basic-2/web/$1 -f [NC] 
RewriteRule ^(.*)$ web/$1 [P,L,QSA] 

RewriteCond %{THE_REQUEST} \ /basic-2/web/([^\?\ ]*) 
RewriteRule^/basic-2/%1 [L,R=301] 
+0

不,这给了我这个错误:_Not found_ '请求的URL /basic-2/index.php没有被找到服务器。 ' –

+0

现在我去睡觉了,我会在12个小时后回来。 –