2016-11-23 89 views
0

我正在使用Slim Framework的最新版本,并且遇到有关url重定向的问题。子目录中的htaccess重定向到域

我的主域是somedomainname.com。我有一个名为santebarley的文件夹,所以我的网址已经是somedomainname.com/santebarley

santebarley文件夹是我的苗条文件所在。所以最后的路由将是somedomainname.com/santebarley/public,因为我的index.php位于公用文件夹中。 .htaccess文件也在公用文件夹中。

我可以访问index.php,尽管我的所有路由都重定向到主域。

例如,我有一个是这样的:

<a href="/">Click me</a> 

要去somedomainname.com/santebarley/public,它直接关系到域robertsoriano.com,或者如果我有像

<a href="/something">Click me</a> 

,而不是去robertsoriano.com/santebarley/something,它也去somedomainname.com

我真的不知道该编辑什么,因为这是我第一次编辑.htaccess文件。该.htaccess文件包含:

RewriteEngine On 

# Some hosts may require you to use the `RewriteBase` directive. 
# If you need to use the `RewriteBase` directive, it should be the 
# absolute physical path to the directory that contains this htaccess file. 
# RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule^index.php [QSA,L] 

我一直在使用之前苗条虽然我想测试一个子目录中。任何帮助将非常感激。

回答

1

您将需要创建在站点根与本规则的.htaccess(在another/santebarley/父目录):

RewriteEngine On 

RewriteRule ^(?!another/santebarley/public/).*$ another/santebarley/public/$1 [L,NC] 
+0

我会尝试。其实,我有somedomainname.com/another/santebarley/public,所以我会把这个.htaccess放在另一个权利? – FewFlyBy

+0

没有在这种情况下使用修改的答案,但仍然在网站根目录 – anubhava

+0

你的意思是在santebarley文件夹内的网站根? – FewFlyBy