May 29, 2013

mod_rewrite, Adding a Condition

A A’s Question:

I have this .htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ zone.php [L]

Right now it works pretty well. How can I make this RewriteRule not work in a certain directory?

I do not want the rule to work for anything in domain.com/manage/

Change your code with this:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule (?!^manage/)^.*$ /zone.php [L,NC]

Add a condition by using the RewriteCond keyword to apply the rule if the directory is not manage

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/manage(/|$)
RewriteRule ^(.*)$ zone.php [L]

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

mod_rewrite, Adding a Condition

A A’s Question:

I have this .htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ zone.php [L]

Right now it works pretty well. How can I make this RewriteRule not work in a certain directory?

I do not want the rule to work for anything in domain.com/manage/

Change your code with this:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule (?!^manage/)^.*$ /zone.php [L,NC]

Add a condition by using the RewriteCond keyword to apply the rule if the directory is not manage

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/manage(/|$)
RewriteRule ^(.*)$ zone.php [L]

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!