Wordpress + Codeigniter htaccess confusing - wordpress

I have Wordpress installed in the root directory with the following htaccess :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
and I have Codeigniter installed in a sub-directories named members, with the following htaccess :
RewriteEngine on
RewriteBase /members/
RewriteCond $1 !^(index\.php|images|templates|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
When I try to access any controller via : site.com/members/controller/function I get the Wordpress 404 error page

In your CI config.php, set your base url as
$config['base_url'] = 'http://site.com/members/'
and change
RewriteBase /members/
to
RewriteBase /
in your CI .htaccess file. This way when you access CI, it doesn't look in the root (which is WP), it goes straight to it's directory and bypasses WP.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cidir
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

Related

Other Wordpress installation on subfolder?

I tried many forum tips to load WP in subfolder, the 2 site is working and can edit the original.com but but can´t login to original.com/en/wp-login.php
Always 404 - Page Not Found.
The webserver is LiteSpeed and the original .htaccess is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# Skip your second WordPress installation
RewriteCond %{REQUEST_URI} !^/(en|en/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
The second site´s .htaccess is:
<IfModule mod_rewrite.c>
RewriteEngine On
# Set the RewriteBase to this directory
RewriteBase /en/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Remove the slash before index.php or we end up at root
RewriteRule . index.php [L]
</IfModule>
Where I making mistake?

.htaccess issue, folder in wordpress?

I have a folder called /mf/ that is not related to the wordpress install but it is in the same root folder. When I visit the folder path (www.domain.com/mf) it gives me a 500 error. I know that this is an .htaccess issue.
I've modded my root .htaccess to do the below code but it still does not work:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/mf/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Any advice on how to fix this .htaccess issue?
in your "mf" folder create a .htaccess file and there put all the configuration that nedded, and in the main folder-wordpress put only the wordpress part.
in th "mf" change the RewriteBase too.
main-wordpress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
the mf folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mf/
RewriteCond %{REQUEST_URI} ^/mf/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>

Accessing Another Directory with Wordpress Installed

I have Wordpress installed on a shared host at Site5. It's installed in the root directory:
www.domain.com
I have another directory that I want to be able to access outside of the Wordpress site:
www.domain.com/directory/
When I visit this URL, I get Wordpress's 404-page. The .htaccess file, as modified by WP, reads:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I assume I need an edit to the .htaccess file to access this directory?
Edit .htaccess present inside "directory"
It should be:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /directory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /directory/index.php [L]
</IfModule>

.htaccess rules to have wordpress in root and cakephp in subfolder

i installed wordpress in the root directory of my FTP, and then in a subfolder I install cakephp, however I have a problem with htaccess.
www/
.htacess
(wordpress)
/folderCakephp/
.htacess
(cakephp)
Wordpress htaccess :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Cakephp root htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Cakephp app/ htaccess :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
Cakephp app/webroot/ htaccess :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
the problem is that when I go on www.domain.com/folderCakephp/ I have a Wordpress 404
In the directory where WordPress is installed, i editing the .htaccess file and i have add the following line. (CakePHP subdirectory will be called "cake")
Wordpress .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^cake/(.*)$ /cake/$1 [L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
/cake .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/app .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /cake
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cake
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
That’s it. You’re good to go.
Visiting example.com in the browser will open your WordPress website, while example.com/cake/, depending on how you configured it, will open your CakePHP app.
I believe the issue is the last line in your WordPress rewrites
RewriteRule . /index.php [L]
This rewrites everthing that isn't picked up by another rule to WordPress. I think you want to change this to match everything but the cakePHP folder using a negative match. I have not tested this, but it should be something like
RewriteRule (?<!folderCakephp). /index.php [L]

Exclude a folder/directory from RewriteRule

I have a pretty standard WordPress .htaccess with the following URL rewrites
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
WordPress is installed in my domain root. I have some other scripts in subfolders, e.g. /opencart These subfolders contain their own .htaccess files.
Unfortunately, it seems that WordPress hijacks the rewrites for some of these scripts sometimes.
How can I ask mod_rewrite to ignore WordPress rules for rewrites when encountered with specific subfolders e.g. opencart and to use the rules defined in the .htaccess within these subfolders instead?
You may try replacing the complete WP rule-set with this one:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI} !(folder1|folder2|folder3) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
In the .htaccess file in your site root, add the following ABOVE the WordPress .htaccess directives:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/subdirectoryname1/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/subdirectoryname2/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^/(folder1)/(.*) /folder1/$2 [R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,R]
</IfModule>
# END WordPress

Resources