我使用的是最新版本的Slim Framework,我在网址重定向方面遇到了问题。
我的主要域名为somedomainname.com
。我的文件夹中有一个名为santebarley
的文件夹,所以我的网址已经是somedomainname.com/santebarley
。
santebarley
文件夹是我的slim文件所在的位置。因此,我的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]
我之前一直在使用slim,虽然我想在子目录中测试它。任何帮助将不胜感激。
答案 0 :(得分:1)
您需要使用以下规则在站点根目录(在another/santebarley/
的父目录中)创建.htaccess:
RewriteEngine On
RewriteRule ^(?!another/santebarley/public/).*$ another/santebarley/public/$1 [L,NC]