[英]Redirecting folder to another folder avoiding other .htaccess rules
I have the root folder of my website with an existing website. 我拥有现有网站的网站根文件夹。 I have developed a codeigniter based admin system which I wish to post in the /editor folder, however all mod_rewriting I have done seems to be in vain as, if anything rewrites, it cant access the input string or the index.php file appears.
我已经开发了一个基于codeigniter的管理系统,希望将其发布在/ editor文件夹中,但是我所做的所有mod_rewriting似乎都是徒劳的,因为如果有任何重写,它就无法访问输入字符串或出现index.php文件。 Here is the structure:
结构如下:
/
/editor
index.php
.htaccess
index.php
.htaccess
Here is my current .htaccess file at the root of the site: 这是我当前在网站根目录下的.htaccess文件:
DirectoryIndex index.php
RewriteEngine On
RewriteRule %{REQUEST_URI}^/?editor/(.*)$ (.*)/editor/$1 [R,L]
RewriteCond $1 ^$
RewriteRule ^(.*)$ ?p=homepage [L]
RewriteCond $1 !^(index\.php|editor|css|pdf|eshot|js|fonts|images)
RewriteRule ^(.*)$ index.php/?p=$1 [L]
Edit 编辑
This current rule displays the root index.php file when you navigate to the /editor sub folder, whereas it should show the index.php file from the /editor folder. 当您导航到/ editor子文件夹时,此当前规则将显示根index.php文件,而应从/ editor文件夹中显示index.php文件。
Re-edit 重新编辑
It might be the .htaccess file in the /editor sub folder, here is the code from that: 它可能是/ editor子文件夹中的.htaccess文件,以下是该代码:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|lib|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Okay, let's look at it step by step. 好吧,让我们逐步看一下它。
First let's scrap this rule, which is ungrammatical because it uses regex on the right side: 首先,让我们废弃此规则,这是不语法的,因为它在右侧使用了正则表达式:
RewriteRule %{REQUEST_URI}^/?editor/(.*)$ (.*)/editor/$1 [R,L]
The second rule can be abridged to this: 第二条规则可以简化为:
RewriteRule ^/?$ ?p=homepage [L]
The third rule can be rewritten like so: 第三条规则可以这样重写:
RewriteRule ^(?!(?:index\.php|editor|css|pdf|eshot|js|fonts|images))([^/.]+)/?$ index.php?p=$1 [L]
Summarizing, it looks to me like you could abridge your rules like so: 总结一下,在我看来,您可以像这样删减规则:
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^/?$ ?p=homepage [L]
RewriteRule ^(?!(?:index\.php|editor|css|pdf|eshot|js|fonts|images))([^/.]+)/?$ index.php?p=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.