使用的.htaccess处理的后端和前端的请求 [英] use .htaccess to deal with requests for backend and frontend

查看:166
本文介绍了使用的.htaccess处理的后端和前端的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有的

首先,我对英语的任何错误道歉

好,我的问题是这样的:

我有了在后端文件夹,并收到以下路径请求

[根] /后端/ WWW (其中包含用于处理请求的index.php文件)

我有了在前端文件夹,并收到以下路径请求

[根] /前端/ WWW (其中包含用于处理请求的index.php文件)

我还一个文件夹命名为通用这是后端和前端之间共享(包含框架的图书馆,以及其他文件)

  

在需要的,是什么时候访问这个位置:

     

^ h ** P://本地主机/安德烈/管理员

     

它改写为:

     

^ h ** P://本地主机/安德烈/后端/ WWW (它目前是如何)


  

在换言之,代替通过访问后端

     

^ h ** P://本地主机/安德烈/后端/ WWW

     

使用这个地址:

     

^ h ** P://本地主机/安德烈/管理员


  

这不指向所有其他要求:

     

^ h ** P://本地主机/安德烈/管理员

     

被访问:

     

^ h ** P://本地主机/安德烈/(即点   ħ**号码://本地主机/安德烈/前端/ WWW)

(我希望你能明白我想要的)

我需要帮助,在某种程度上与做到这一点的的.htaccess 的文件,我不能使用符号连接或子域对于这个问题...

我搜索了很多在谷歌这里,却发现没有什么工作,或谁可以帮我。

PS:我使用Yii框架与YiiBoilerplate,但我认为该解决方案不应该在那里

在此先感谢!

解决方案

解决,与此code:

  RewriteEngine叙述上
的RewriteBase /安德烈/

重写规则^管理(/.*)?$后端/ WWW / index.php文件/ $ 1 [L,NC]

的RewriteCond%{REQUEST_URI} /!(前端|后端)/ [NC]
重写规则^(。*)?$前端/ WWW / index.php文件/ $ 1 [L,NC]
 

First of all, I apologize for any mistake in English

well, my question is this:

I have a folder that has the backend, and receives requests in the following path

[root]/backend/www(which contains an index.php file that handles requests)

I have a folder that has the frontend, and receives requests in the following path

[root]/frontend/www(which contains an index.php file that handles requests)

I have also a folder named common that is shared between the backend and frontend (contains the libraries of the framework, among other files)

what in need, is when the access to this location:

h**p://localhost/andre/admin

rewrite it to:

h**p://localhost/andre/backend/www (how it currently is)


In other words, instead of accessing the backend by:

h**p://localhost/andre/backend/www

use this address:

h**p://localhost/andre/admin


all other requests that do not point to:

h**p://localhost/andre/admin

be accessed by:

h**p://localhost/andre/ (ie, point to h**p://localhost/andre/frontend/www)

(I hope you can understand what I want)

I need help, on a way to do this with .htaccess file, I can not use Symlinks or Subdomains for this problem...

I've searched a lot in Google and here, but found nothing that worked or who could help me.

PS: I am using Yii Framework with YiiBoilerplate, but I think the solution should not be out there

Thanks in advance!

解决方案

Solved, with this code:

RewriteEngine On
RewriteBase /andre/

RewriteRule ^admin(/.*)?$ backend/www/index.php/$1 [L,NC]

RewriteCond %{REQUEST_URI} !/(frontend|backend)/ [NC]
RewriteRule ^(.*)?$ frontend/www/index.php/$1 [L,NC]

这篇关于使用的.htaccess处理的后端和前端的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆