Search code examples
.htaccessmod-rewriteexpressionengine

Rewrite Condition partial match causing problems


I have the following rewrite rule in my .htaccess file on the root of an ExpressionEngine site to remove the index.php portion of the URL...

RewriteEngine on 
RewriteCond $1 !^(resources|media|images|js|css|fonts|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

Which works fine.

However the client now wants a page called "Media Centre" with the URL www.domain.com/media-centre which is being ignored because "media" is triggering a match in the rewrite condition.

How do I tell it to ignore "media" but not "media-centre"?

Thanks.


Solution

  • Maybe add a $ at the end?

    RewriteCond $1 !^(resources|media|images|js|css|fonts|favicon\.ico|robots\.txt|index\.php)$ [NC]
    

    Or maybe just explicity allow "media-center":

    RewriteCond $1 ^(media-centre) [OR]
    RewriteCond $1 !^(resources|media|images|js|css|fonts|favicon\.ico|robots\.txt|index\.php) [NC]