简体   繁体   English

不同文件夹的不同.HTACCESS

[英]Different .HTACCESS for different folders

I have a problem when configuring .htaccess for different folders. 为其他文件夹配置.htaccess时出现问题。 I have the folder structure mentioned below. 我有下面提到的文件夹结构。

root/
|-- resources/
|-- config/
|-- libraries/
|-- admin/
|    |-- resources/
|    |-- config/
|    |-- libraries/
|    |-- index.php
|    |-- .htaccess
|-- index.php
|-- .htaccess

I need to configure the htaceess for the root and admin folder. 我需要为根目录和admin文件夹配置htaceess。 I need the .htaccess from the root to ignore the admin folder, but when the url has admin folder it should use the .htacess file from the admin folder. 我需要从根目录访问.htaccess来忽略admin文件夹,但是当url具有admin文件夹时,它应该使用admin文件夹中的.htacess文件。 For example 例如

www.domain.com/person/add
www.domain.com/person/edit/1
www.domain.com/person/view/1

should use the .htaccess file from the root. 应该从根目录使用.htaccess文件。 When the url has admin folder it should use the .htaccess file from the admin folder. 网址具有admin文件夹时,应使用admin文件夹中的.htaccess文件。 For example 例如

www.domain.com/admin/person/add
www.domain.com/admin/person/edit/1
www.domain.com/admin/person/view/1

The below is the root .htaccess file that I configured. 以下是我配置的根.htaccess文件。

RewriteEngine On
RewriteCond %{REQUEST_URI} !^(admin)
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

But it doesn't work for the admin folder. 但不适用于admin文件夹。 How to configure the .htaccess file for both root and the admin folder. 如何为根和admin文件夹配置.htaccess文件。

This should work for you, you almost had it: 这应该为您工作,您几乎拥有它:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

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

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