We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Help with .htaccess for specific purpose

Development and Programming

dimitar.mihaylov's avatar
dimitar.mihaylov
35 posts
15 years ago
dimitar.mihaylov's avatar dimitar.mihaylov

Hey everybody,

I need some help with setting up a .htaccess file for my EE2 installation. I have a web folder, where my index.php file takes place:

/folder/.htaccess
/folder/index.php

What I have there as well is another folder with its own index.php and .htaccess file:

/folder/cifolder/.htaccess
/folder/cifolder/index.php

So, “folder” is the EE2 one, while “cifolder” is referring to CodeIgniter website. The end goal is:

http://website.com/ - to open EE website http://website.com/cifolder/ - to open CI website

This is what I currently have in /folder/.htaccess:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

It does the magic, if I open http://website.com/cifolder/. However, if I try http://website.com/cifolder/something-else, I get 404 from EE. What else do I need to put in my .htaccess file?

Thanks! 😊

       
hd 's avatar
hd 
156 posts
15 years ago
hd 's avatar hd 

I’m no .htaccess expert but I’d try:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|cifolder)
RewriteRule ^(.*)$ index.php/$1 [L]

…so that your cifolder links do not get handled by EE.

And then inside the “cifolder” put another .htaccess to handle removing that nested index.php using code like what you’ve posted.

       
dimitar.mihaylov's avatar
dimitar.mihaylov
35 posts
15 years ago
dimitar.mihaylov's avatar dimitar.mihaylov

Thanks, HD. Unfortunately, this combination doesn’t work, too. I presume that something else is needed in this line in order to “tell” to not check anything after /cifolder/, not just the folder itself:

RewriteCond $1 !^(index\.php|cifolder)
       
hd 's avatar
hd 
156 posts
15 years ago
hd 's avatar hd 

Have you tried also removing the file & dir checking…

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

You may have to explicitly list image/css/robots.txt/etc inside that line along with cifolder.

       
dimitar.mihaylov's avatar
dimitar.mihaylov
35 posts
15 years ago
dimitar.mihaylov's avatar dimitar.mihaylov

Yes, I tried that as well, no luck indeed. There is nothing else in this folder, but .htaccess, index.php and cifolder, so what I need to exclude is the latter only.

       
Chuck Liddell's avatar
Chuck Liddell
57 posts
15 years ago
Chuck Liddell's avatar Chuck Liddell

Here is what I use on my site:

RewriteEngine on
RewriteCond $1 !^(index\.php|admin\.php|app1\.php|app2\.php|assets|lib|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Everything is passed to index.php except the things I list explicitly.

admin.php, app1.php, app2.php are all loaders (admin is EE backend, app1 and app2 are CodeIgniter apps).

I keep all my images, css, javascript in the ‘assets’ folder, so calls to one of these look like this:

Hope this helps.

       
dimitar.mihaylov's avatar
dimitar.mihaylov
35 posts
15 years ago
dimitar.mihaylov's avatar dimitar.mihaylov

Okay, figured it out. Following line was taking place in /cifolder/.htaccess:

RewriteBase /

Works now. Thanks for help, guys! 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.