0

I want to redirect subdomain.example.com to newsubdomain.example.com. Both are working under the same redirect rules, but one of these rules is does not do what I need it to do. I need a 301 redirect under a new rule (using another URL structure).

Example: http://subdomain.example.com/c/138 to http://newsubdomain.example.com/138/

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

RewriteCond %{QUERY_STRING} ^c/([^&]+)
RewriteRule ^/?category\.php$ http://www.alarab.com/%1/ [L,R=301]

Any suggestions?

Thanks

Justin R.
  • 489
  • 1
  • 5
  • 12

1 Answers1

0

The second rule isn't relevant here, only the first one.


There are two ways to do a wholesale redirect. One would be your attempt with RewriteRule, but you must capture only the final path part after /c, e.g.

RewriteRule ^c/(.*)$ http://www.example.com/$1 [L,R,NC]

The second way would be with Redirect from mod_alias

Redirect /c http://www.example.com

Both ways capture the part after the prefix and slap it onto the target path.


Finally, unrelated, never test with R=301!

Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198