Forum

Converting Apache .htaccess to URL Toolkit

Rewrite rule
23 June 2016, 18:14
Hi,
I need to convert these Apache htaccess rules:

RewriteCond %{REMOTE_ADDR} !^(110\.174\.129\.147|203\.217\.17\.162)
RewriteCond %{HTTP_USER_AGENT} !(Googlebot|msnbot|Surp) [NC]
RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301,NE]
RewriteRule ^brands$ http://www.website.com/brand [R=301,L]
alexpacio
23 June 2016, 18:15
Could you help me to understand how to convert them?

Thanks in advance
alexpacio
23 June 2016, 18:29
I'd also have to translate this rule:
RewriteRule ^brands/(.*) /brand/$1 [R=301,NC,L]
Hugo Leisink
24 June 2016, 00:26
Hiawatha has no equivalent for this:
RewriteCond %{REMOTE_ADDR} !^(110\.174\.129\.147|203\.217\.17\.162)
RewriteCond %{HTTP_USER_AGENT} !(Googlebot|msnbot|Surp) [NC]


The other two lines will be this:
Match ^/(.*)$ Redirect http://www.website.com/$1
Match ^/brands$ Redirect http://www.website.com/brand

However, the first line does what the second like does. So, the second line is obviate.

The rule from your last message is this:
Match ^/brands/(.*) Redirect /brand/$1


To learn to do this yourself, learn about regular expressions and read the Hiawatha manual page. It's all in there.
alexpacio
24 June 2016, 15:23
Great Hugo!
I didn't know how to match the rule on IP and http user agent basis, since it wasn't documented.
Thanks for your tip!
This topic has been closed.