Welcome to WebmasterWorld Guest from 54.210.61.41
Forum Moderators: Ocean10000 & phranque
joined:Nov 28, 2016
posts: 10
votes: 0
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.
joined:Nov 28, 2016
posts: 10
votes: 0
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.
joined:Nov 28, 2016
posts: 10
votes: 0
Yes this is just 1 redirect.
There are no other possible parameters that are not to be redirected.
Well i have 4 such urls in ahrefs and each one has some google power in it
Google has indexed all 4 with parameters..
joined:Nov 28, 2016
posts: 10
votes: 0
RewriteRule http://www.example.com/topsites/in.php https://example.net/product/ [L,R=301]
joined:Nov 28, 2016
posts: 10
votes: 0
So you want requests for "/topsites/in.php?id=name(any single digit number)" to go to "https://example.net/product/"?
You will be sending visitors from all 4 pages to one different directory
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.
1. The rule has no RewriteCondI hope you weren’t saying that RewriteRules have to have Conditions. They don’t. In particular, if you have old redirects that you shifted over from mod_alias, they will come through without conditions because none are needed.