duanpai9945 2014-04-04 13:26
浏览 29

不同的.HTACCESS用于不同的文件夹

I have a problem when configuring .htaccess for different folders. 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. 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. 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. When the url has admin folder it should use the .htaccess file from the admin folder. 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.

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

But it doesn't work for the admin folder. How to configure the .htaccess file for both root and the admin folder.

  • 写回答

1条回答 默认 最新

  • dongmu5106 2014-04-04 14:47
    关注

    This should work for you, you almost had it:

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

报告相同问题?

悬赏问题

  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程