在一个网站的多个Mod_ReWrites - 可能吗? (字preSS博客的根目录下的子目录codeIgniter项目) [英] Multiple Mod_ReWrites on one site - Possible? (Wordpress blog in root directory, CodeIgniter project in subdirectory)

查看:131
本文介绍了在一个网站的多个Mod_ReWrites - 可能吗? (字preSS博客的根目录下的子目录codeIgniter项目)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我创造与codeIgniter被包含在我的域的子目录中的项目。在这个例子中,我们把它叫做domain.com/test。

Currently I am creating a project with CodeIgniter that is contained within a subdirectory of my domain. For this example we'll call it domain.com/test.

我也有安装在此领域字preSS,和它的所有文件都在根目录下。例如,如果您浏览到我的domain.com然后将其拉起来的话preSS博客。目前,我有话preSS mod_rewrite的激活,使其使用友好-的URL。

I also have Wordpress installed on this domain, and all of its files are in the root. For instance, if you navigate to my domain.com then it pulls up the Wordpress blog. I currently have the Wordpress mod_rewrite activated so that it uses friendly-URLs.

对于那些你不熟悉的codeIgniter,所有的请求都通过index.php文件在项目的根文件夹传送。所以,在这种情况下,这将会是domain.com/text/index.php。的请求的应用程序将要发送像domain.com/test/index.php/somecontroller/method

For those of you that aren't familiar with CodeIgniter, all requests are routed through index.php in the project's root folder. So, in this case, it'd be domain.com/text/index.php. A request to the application would be sent like domain.com/test/index.php/somecontroller/method.

我想要做的,是因为这是朝向/测试/文件夹,或一些子目录,其中我想它适当地重写URL,这样的index.php文件不包含任何传入的请求。 (根据上面的例子,它会最终被domain.com/test/somecontroller/method)

What I'd like to do, is for any incoming request that is directed towards the /test/ folder, or some subdirectory therein I'd like it to appropriately rewrite the URL so the index.php isn't included. (As per the example above, it'd end up being domain.com/test/somecontroller/method)

有关任何其他要求,这意味着什么,这不是/测试/目录下,我想这将请求路由到Word preSS。

For any OTHER request, meaning anything that's not within the /test/ directory, I would like it to route the request to Wordpress.

我会想象它是一个简单的RewriteCond使它检查,看看是否该请求是针对/测试/目录或子目录内,但我不知道该怎么做。也许你不能每个站点不止一组重写规则。

I would imagine it's a simple RewriteCond to make it check to see if the request is for the /test/ directory or a subdirectory therein, but I've no idea how to do it. Perhaps you can't have more than one set of Rewrite Rules per site.

我将包括每个应用程序的建议mod_rewrite规则。

I will include the recommended mod_rewrite rules for each application.

字preSS:(现在使用的)

Wordpress: (Currently used)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

codeIgniter:(从维基拉)

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

任何及所有的帮助是非常AP preciated !!

Any and all help is much appreciated!!

谢谢

-Sootah

推荐答案

@Myself和Stormdrain - 正如上面我的评论(以及Stormdrain阐述时),只需把codeIgniter的.htaccess在/测试/子目录奏效了。

@Myself and Stormdrain - As stated in my comment above (and expounded upon by Stormdrain), simply putting the CodeIgniter .htaccess in the /test/ subdirectory did the trick.

嗯,我还应该注意到,我也必须从这个修改codeIgniter的.htaccess BasePath行:     的RewriteBase /

Ah, I should also note that I did have to modify the CodeIgniter .htaccess BasePath line from this: RewriteBase /

这样的:     的RewriteBase /测试/

to this: RewriteBase /test/

希望这有助于任何人具有相同/相似的问题。

Hopefully this helps anybody else that has the same/a similar question.

- Sootah

这篇关于在一个网站的多个Mod_ReWrites - 可能吗? (字preSS博客的根目录下的子目录codeIgniter项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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