views:

21

answers:

2

All the advice online says do: rewrite 301 URL-A URL-B

But that won't work if I turn on mod_rewrite (it seems?) with RewriteEngine on

So, I'm bad a regex, but shouldn't need it here. How do I do:

RewriteCond %{HTTP_HOST} ^untamed-adventures.com/travel/How/tabid/58/Default.aspx [NC] 

RewriteRule ^(.*)$ http://untamed-adventures.com/ [R=301,L]
A: 

Not at all clear what you're trying to do. HTTP_HOST is the hostname part in the requested URL, in this case, "untamed-adventures.com", so that RewriteCond will never match.

I think that what you're trying to do is:

Redirect 301 /travel/How/tabid/58/Default.aspx http://untamed-adventures.com/

In which case, mod_rewrite isn't needed at all.

Rich Bowen
There are other instructions in the file that require mod_rewrite.
Dan
A: 

%{HTTP_HOST} expands to the host of the request, so it could never match untamed-adventures.com/travel/How/tabid/58/Default.aspx, only untamed-adventures.com.

If you want to forward http://untamed-adventures.com/travel/How/tabid/58/Default.aspx to http://untamed-adventures.com/, try this:

RewriteCond %{HTTP_HOST} =untamed-adventures.com
RewriteRule ^/travel/How/tabid/58/Default.aspx$ http://untamed-adventures.com/ [R=301]

The L flag is redundant; a forward is always final.

Artefacto
Ah, the RewriteRule bit works except one must drop the leading /Cheers very much!
Dan
@Dan only if in a .htaccess or if you've set `RewriteBase /`
Artefacto
Ah ha! Yes, was in .htaccess.
Dan