简体   繁体   English

子目录中的htaccess重定向到域

[英]htaccess inside the subdirectory redirects to domain

I am using the latest version of Slim Framework and I'm having problems regarding url redirecting. 我正在使用最新版本的Slim Framework,并且在有关URL重定向方面遇到问题。

My main domain is somedomainname.com . 我的主要域名是somedomainname.com I have a folder inside it named santebarley so my url is already somedomainname.com/santebarley . 我在其中有一个名为santebarley的文件夹,因此我的网址已经是somedomainname.com/santebarley

The santebarley folder is where my slim files reside. santebarley文件夹是我的苗条文件所在的位置。 So the final route would be somedomainname.com/santebarley/public since my index.php is in the public folder. 因此,由于我的index.php位于公用文件夹中,所以最终路由为somedomainname.com/santebarley/public The .htaccess file is also in the public folder. .htaccess文件也位于公用文件夹中。

I can access the index.php though all of my routes redirect to the main domain. 尽管我所有的路由都重定向到主域,但我仍可以访问index.php

For example, I have a something like this: 例如,我有这样的东西:

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

Instead of going to somedomainname.com/santebarley/public , it goes to the domain robertsoriano.com or if I have something like 而不是去somedomainname.com/santebarley/public ,而是去了robertsoriano.com域,或者如果我有类似的东西

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

Instead of going to robertsoriano.com/santebarley/something , it also goes to somedomainname.com . 而不是去robertsoriano.com/santebarley/something ,它也去了somedomainname.com

I really don't know what to edit since this is my first time editing a .htaccess file. 我真的不知道要编辑什么,因为这是我第一次编辑.htaccess文件。 The .htaccess file contains: .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]

I've been using slim before though I want to test it inside a subdirectory. 尽管我想在子目录中对其进行测试,但我一直在使用slim。 Any help would be much appreciated. 任何帮助将非常感激。

You will need to create a .htaccess in site root (in the parent directory of another/santebarley/ ) with this rule: 您将需要使用以下规则在站点根目录(在another/santebarley/的父目录中)中创建一个.htaccess:

RewriteEngine On

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM