user1823053
user1823053

Reputation: 69

.htaccess file redirect to dynamic page

I am currently using

RewriteRule ^(.*).html$ location.php?cmd=$1 [L]

to redirect all .html page requests via a dynamic page - location.php.

How I can add exceptions to allow 2 or 3 pages to not be affected by this rule eg. index.html aboutus.html etc. thanks.

Upvotes: 0

Views: 49

Answers (2)

anubhava
anubhava

Reputation: 784998

Replace your code with:

 RewriteCond %{REQUEST_URI} !^/(index|aboutus|contact)\.html$ [NC=
 RewriteRule ^(.+?)\.html$ /location.php?cmd=$1 [L]

Upvotes: 0

Joran Den Houting
Joran Den Houting

Reputation: 3163

Place these lines at the top of your .htaccess file to skip to existing files and directories if they exist. If not, proccess our other rules as usual.

RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule .* - [L]

Upvotes: 1

Related Questions