简体   繁体   English

.htaccess-仅重定向root(Codeigniter / WordPress)

[英].htaccess - redirecting ONLY root (Codeigniter / WordPress)

I currently have a site created in codeigniter in a folder /ci/ 我目前在/ci/文件夹中的codeigniter中创建了一个网站

I currently installed WordPress in the root directory. 我目前在根目录中安装了WordPress。

What I want is the site to perform as normal with CI but for the main root url (www.example.com) I want it to load the the Wordpress site (hence why i installed it in the root) 我想要的站点是使用CI正常运行的站点,但对于主根URL(www.example.com),我希望它加载Wordpress站点(因此我将其安装在根目录中)

I am trying in the .htaccess to IGNORE the main site from being redirected to CI with: 我想在.htaccessIGNORE被重定向到CI与主站点:

RewriteCond %{REQUEST_URI} !^/

But as expected this means all the the other CI links (eg http://www.example.com/test which is http://www.example.com/ci/test ) no longer work. 但是,正如预期的那样,这意味着所有其他CI链接(例如http://www.example.com/test ,即http://www.example.com/ci/test )不再起作用。


This is my current .htaccess file: 这是我当前的.htaccess文件:

Options -Indexes +SymLinksIfOwnerMatch 
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_URI} !^/
RewriteCond %{REQUEST_URI} !^/ci/
RewriteCond %{REQUEST_URI} !^/wp-admin/?$
RewriteCond %{REQUEST_URI} !^/wp-content/?$
RewriteCond %{REQUEST_URI} !^/wp-includes/?$

RewriteRule ^(.*)$ /ci/$1 [L]

I am assuming that www.example.com is wordpress site. 我假设www.example.com是wordpress网站。 and in wordpress site a folder named CI holds a CI website. 在wordpress网站中,名为CI的文件夹保存一个CI网站。

Ok. 好。 So follow these steps: First allow /CI directory from your wordpress site. 因此,请按照下列步骤操作:首先从您的wordpress网站允许/ CI目录。 include this line 包括这行

RewriteRule ^CI/(.*)$ /CI/$1 [L,QSA]

and in CI site you have htaccess just add this line there. 在CI网站中,您具有htaccess,只需在此添加此行。

RewriteBase /CI

Hope this can help. 希望这会有所帮助。

I am not going to say what you want cannot be done, but for the sake of 'keeping your house in order', you should move the /test folder to ci/test and be done with it. 我不会说您无法完成什么,但是为了“保持房子秩序”,您应该将/ test文件夹移至ci / test并完成它。 Otherwise you are confusing both WordPress working out of your root directory and Code Igniter working out of your /ci folder. 否则,您会混淆WordPress在根目录下的工作以及Code Igniter在/ ci文件夹下的工作。

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

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