Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess in subfolder

The main site runs WordPress with .htaccess

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

I'm going to create an CodeIgniter app in subdirectory site.com/online/ If simply add CI .hta file in subfolder it wouldn't work. CI .htaccess:

RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|img|styles|js)
RewriteRule ^(.*)$ /index.php?/$1 [L]

Is it possible to combine two .htaccess files or to do something with .htaccess in CI subfolder? Thank you.

UPD. Thank you for answers, I've tried all variants, and eventually moved project to subdomain.


1 Answers

First thing, your .htaccess should be like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} !^GET\s/+online/ [NC]
RewriteRule . /index.php [L]
</IfModule>

#Then add this for CI handling in the same .htaccess
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !index\.php [NC]
RewriteRule ^online/(.*)$ online/index.php?/$1 [L,NC]

Then you can remove (or rename) .htaccess in the online subfolder.

like image 130
anubhava Avatar answered Feb 12 '26 14:02

anubhava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!