Forum Moderators: phranque
http://www.example.com/topsites/in.php?id=name and need it to go to https://example.net/product/ RewriteEngine on
RewriteRule http://www.example.com/topsites/in.php?id=name https://example.net/product/ [L,R=301] [edited by: phranque at 11:14 pm (utc) on Jun 20, 2018]
[edit reason] Please Use example.com [webmasterworld.com] [/edit]
RewriteRule http://www.example.com/topsites/in.php?id=name
will this do it?Sorry, no, for two separate but related reasons.
so will this do it?
RewriteRule /topsites/in.php?id=name https://example.net/product/ [L,R=301]
the Pattern of a RewriteRule directive "is matched against only a partial path".
source: https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
therefore it won't match the hostname or the query string specified in the Pattern.
you can use RewriteCond directives prior to the RewriteRule to match these if necessary.
#2 Parameters have to go in a RewriteCond, because the body of the rule doesn't see them.
so will this do it?No, for at least one and possibly two reasons.
RewriteRule http://www.example.com/topsites/in.php?id=name1 https://example.net/product/ [L,R=301] is not a valid rule because: #1 If your pattern includes “http://example.com/” then mod_rewrite will never recognize the URL, hence conditions (if any) won't be evaluated, and the rule will never execute.
#2 Parameters have to go in a RewriteCond, because the body of the rule doesn't see them.
the Pattern of a RewriteRule directive "is matched against only a partial path".
source: https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
therefore it won't match the hostname or the query string specified in the Pattern.
you can use RewriteCond directives prior to the RewriteRule to match these if necessary.