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

modifying EE recommended Mod Rewrite to ignore folder with similar name?

How Do I?

chris thacker's avatar
chris thacker
112 posts
9 years ago
chris thacker's avatar chris thacker

i’m trying to tweak the recommended Rewrite for our use.

The main site and subpages work but it needs to be modified because some web page assets are stored in similarly named directories.

The recommended Rewrite provided by Ellislabs is this and I’ve modified it a little to work with our server:

RewriteEngine On
RewriteBase /

# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) abc/$1$2 [R=301,NE,L]

# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ abc/index.php?/$1 [L]

EE is installed in a folder called /abc/.

For example, the URL http://oursite.example.com/abc works.

Subpages are mostly working and I suspect this applies to any page really but I’m noticing it on subpages. It removes index.php and mostly loads, such as http://oursite.example.com/abc/subdept/page/

However our developer has some assets kept in a server directory named /uploads/abc/ so if a page tries to load images from this directory, it fails to load those assets because it contains the same name, “abc”.

Thus, what is the best way to handle this?

I’m guessing I can either tell it to ignore “uploads/cls” or correct the current Rewrite so that it only looks at the first “abc”. I’d like for the solution to cover most similar issues that would arise so I don’t have to keep modifying it. We have 12 sites and I’ll have to apply the solution to each one.

Everything I’ve tried hasn’t worked.

Also, I thought !-f and !-d would tell it to ignore it if the file or directory existed and that doesn’t seem to be working as I’d expect here because these images in /uploads/abc/ do exists.

Thanks!

       
chris thacker's avatar
chris thacker
112 posts
9 years ago
chris thacker's avatar chris thacker

The problem was with the template and not the rewrite. It’s working now.

       
Derek Jones's avatar
Derek Jones
7,561 posts
9 years ago
Derek Jones's avatar Derek Jones

Glad you figured it out, chris! I looked at this one earlier this morning and was scratching my head a bit… 😉

       

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.