简体   繁体   English

htaccess-使用子域和管理员目录

[英]htaccess - using subdomains and admin dir

I have .htaccess like this code: 我有.htaccess这样的代码:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/(.*)?$ admin/index.php?a=$1 [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^(www.)?(([^.]+).)?domain.com [NC]
RewriteRule ^(.*)$ index.php?s=%3&d=domain.com&a=$1 [QSA,NC,L]

I need access to directory /admin where is index.php and use subdomains also. 我需要访问目录/ admin,其中index.php并使用子域。 Access to admin is ok, when i remove: RewriteCond %{HTTP_HOST} ^(www.)?(([^.]+).)?domain.com [NC] 当我删除时,可以访问管理员: RewriteCond %{HTTP_HOST} ^(www.)?(([^.]+).)?domain.com [NC]

The dir look like: index.php; admin/index.php 目录如下: index.php; admin/index.php index.php; admin/index.php

Can somebody help me, what i do bad? 有人可以帮助我,我做错了吗?
Any information helps, thank you. 任何信息都会有所帮助,谢谢。

You can skip /admin from 2nd rule like this: 您可以从第二条规则中跳过/admin ,如下所示:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^admin/(.*)$ admin/index.php?a=$1 [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/admin [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?(([^.]+)\.)?domain\.com$ [NC]
RewriteRule ^(.*)$ index.php?s=%3&d=domain.com&a=$1 [QSA,L]

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

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