Forum Moderators: phranque
[site.com...]
to be forwarded to this:
[site.com...]
With the "###" being a varying number...
I've looked at many tutorials but hours later I've gotten nowhere!
Thanks in advance for any help.
Both are possible, and it is very easy if the '###' part is the exact same number on both of them.
You'll need a
RewriteCond to look at QUERY_STRING and a RewriteRule to do the actual work - but do you need a redirect or a rewrite here?
[R=301,L] on the end of the rule, and the target URL of the redirect will need to state the protocol and hostname as well as the path and parameters. There's quite a lot of prior example code for doing similar stuff to that. Post your best effort code back here, using the clues above, as a basis for discussion.
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/subfolder/\$
RewriteCond %{QUERY_STRING} ^value=click&class=([0-9]*)$
RewriteRule ^(.*)$ [site.com...] [R=301,L]
for [site.com...] to [site.com...]
[edited by: RachelA at 10:38 am (utc) on April 25, 2009]
RewriteEngine On
RewriteCond %{QUERY_STRING} [b]&?[/b]value=click&class=([0-9][b]+[/b])[b]&?[/b]
RewriteRule ^[b]subfolder/[/b](.*)$ http://www.site.com/[b]$1[/b]?id=[b]%1[/b] [R=301,L] Be aware that it only responds to the parameters being in a particular order. If they are in a different order in the request, the rule will fail to run.
Does the
'value=click' parameter *have* to be present, for the redirect to be needed? You need to think that through a bit more. I also changed it so that the
class parameter cannot be blank. It must have one or more digits within. Is that correct for your application? I don't know if you also need to carry over any filename path part. I did include that, above, and omitted it below:
RewriteEngine On
RewriteCond %{QUERY_STRING} [b]&?[/b]value=click&class=([0-9][b]+[/b])[b]&?[/b]
RewriteRule ^[b]subfolder/[/b] http://www.site.com/?id=[b]%1[/b] [R=301,L] You need to think about what happens when someone requests a subtly wrong URL. Do you want to redirect it, or make it fail as a 404 error? You will need to test what the code actually *does* with that request, and amend the code to fit what you actually need it to do.
Thank you so much again for taking the time out to help me, I really appreciate your time.
Take care :)
Example;
[mysite.com...] needs to be redirected to a secure ssl certificate version of the site which has the address of [mysite.com...]
Would redirecting all traffic be possible by using a .htaccess redirect 301 by using code:
redirect 301 /http://www.mysite.com/https://mysite.com
and then saving the .htaccess in the ROOT folder on an Apache Server?