简体   繁体   English

htaccess重写规则访问文件夹而不移动它

[英]htaccess rewrite rule accesing folder without moving it

I have an root folder like this: 我有一个像这样的根文件夹:

ROOT
|- Service
|  |- Admin
|
|- Service 2

I'm interesting in accessing the admin folder from service folder 我对从服务文件夹访问admin文件夹很感兴趣

To access the admin path via url i use mydomain.com/Service/Admin 要通过url访问管理路径,请使用mydomain.com/Service/Admin

Is there any way to make it access like this mydomain.com/Admin without moving folders? 有什么方法可以使它像mydomain.com/Admin这样访问而无需移动文件夹?

You can try this rule in your DOCUMENT_ROOT/.htaccess file: 您可以在DOCUMENT_ROOT/.htaccess文件中尝试以下规则:

RewriteEngine On

RewriteRule ^(Admin/.*)$ Service/$1 [L,NC]

.htaccess 的.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^Admin/ Service/Admin/index.php [L]
</IfModule>

I haven't tested this, but i believe it should work 我还没有测试过,但是我认为它应该可以工作

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

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