1

We are running WordPress and CodeIgniter in the same domain, separated by subfolders. We know it's not the best practice, but CodeIgniter will be a temporary thing until we fully move to WordPress.

I was wondering if anybody could help me with an .htaccess file to allow WordPress and CodeIgniter to run without clashing with each other.

For some reason WordPress configuration is taking over the entire site.

public_html/
 .htaccess (blank)
 /wordpress/
 /codeigniter/

To access WordPress, we use domain.com and to use CodeIgniter we use domain.com/codeigniter. Everything works fine but CodeIgniter keeps redirecting to the WordPress site.

.htaccess

@PatJ Hello - yes i've copy .htaccess in both directories public_html/ and 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
  • Is there a .htaccess file in your /wordpress/ directory? How do you have it set up that accessing domain.com loads the WordPress site? – Pat J Jan 6 '15 at 16:31
  • @PatJ Hello - yes i've copy .htaccess in both directories public_html/ and wordpress/ – misterzik Jan 6 '15 at 19:37
2

Maybe try something like this..

.htaccess on your root:

# 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

.htaccess inside your /wordpress/ directory:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress

.htaccess in your /codeigniter/ directory:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /codeigniter/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /codeigniter/index.php [L]
</IfModule>

# END WordPress
1

Your .htaccess rules are cascading from the level they are defined on downwards. So in this case whatever rules you have in root apply to both subfolders.

You need:

  1. Only rules that affect whole site in root
  2. Any WordPress rules in subfolder it's in
  3. And same for CodeIgniter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.