Ellinor
Ellinor

Reputation: 323

Multiple rewrite rules to different pages

I am trying to create multiple rewrite rules, so that a few pages will be redirected to certain pages, and the rest will be redirected to the start page. However, all my pages keep getting redirected to the start page.

This is the code I am using:

RewriteCond %{HTTP_HOST} ^site\.com/category\.php?s=1$ [NC]
RewriteRule (.*) http://site.co.uk/category/? [R=301,L]


RewriteCond %{HTTP_HOST} ^site\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.site\.com$ [NC]
RewriteRule (.*) http://site.co.uk/? [R=301,L]

Edit:

This is the full .htaccess:

Order deny,allow
DirectoryIndex default.php index.php
SetEnv DEFAULT_PHP_VERSION 5


Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} /flavours\.php?\s=1 [NC]
RewriteRule ^ http://site.co.uk/flavours/? [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?site\.com$ [NC]
RewriteRule ^ http://site.co.uk/? [R=301,L]

This is the link I am trying to access: www.site.com/flavours.php?s=1

Upvotes: 1

Views: 290

Answers (1)

anubhava
anubhava

Reputation: 786001

HTTP_HOST cannot match REQUES_URI.

You can use:

# specific redirects
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} /flavours\.php\?s=1 [NC]
RewriteRule ^ http://site.co.uk/flavours/? [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?flaverco\.com$ [NC]
RewriteRule ^ http://site.co.uk/? [R=301,L]

Make sure to clear your browser cache before testing this.

Upvotes: 1

Related Questions