问题描述
目前我正在使用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.
我也在这个域安装了Wordpress,所有的文件都在根。例如,如果你导航到我的domain.com,那么它拉起Wordpress博客。我目前有Wordpress 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.
我想要做的是,请求指向/ test /文件夹或其中的一些子目录,我希望它适当地重写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)
对于任何其他请求,意味着任何不在/测试/目录,我想它路由请求到Wordpress。
For any OTHER request, meaning anything that's not within the /test/ directory, I would like it to route the request to Wordpress.
我想象这是一个简单的RewriteCond,使它检查,看看请求是否为/ test /目录或其中的子目录,但我不知道如何做到。
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.
Wordpress:(目前使用)
Wordpress: (Currently used)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
CodeIgniter:(从)
CodeIgniter: (Pulled from their Wiki)
<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>
任何和所有的帮助是非常赞赏的!
Any and all help is much appreciated!!
感谢,
-Sootah
推荐答案
@自己Stormdrain - 如我在上面的评论(和Stormdrain阐述的),简单地把CodeIgniter .htaccess放在/ test /子目录中做的伎俩。
@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 / test /
to this: RewriteBase /test/
希望这有助于任何具有相同/类似问题的人。
Hopefully this helps anybody else that has the same/a similar question.
-
这篇关于一个站点上的多个Mod_ReWrites - 可能? (Wordpress博客在根目录下,CodeIgniter项目在子目录下)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!