Trying to get this -
hxxps://www.olddomain.com/bbs/index.php?action=printpage;topic=364.0
to redirect to this -
hxxps://www.newdomain.com/forum/index.php?action=printpage;topic=364.0
Currently using this -
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} olddomain.com [NC]
RewriteRule ^(.*)$ https://www.newdomain.com/forum/index.php [R=301,NC]
Redirects first link to new domain main index, action is lost.
Last time I did this...
RewriteCond %{HTTP_HOST} !^www\.olddomain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) https://www.newdomain.com/$1 [L,R,NE]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]
First part fixes requests from the old domain to the new (and handles cases of empty host header), the second part ensures using HTTPS - and in all cases preserving the query string.
Doesn't work, get page can't be displayed error for old printpage link. Domain redirect works. The subdir is different on old and new.
That's what I get for just digging out my material that just has the forum at top level.
I'd assume you could tweak it thus:
RewriteCond %{HTTP_HOST} !^www\.olddomain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/bbs/?(.*) https://www.newdomain.com/forum/$1 [L,R,NE]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.newdomain.com/$1 [R=301,L]
Still doesn't work. It has to redirect from olddomain/bbs/ to newdomain/forum/ without losing the action. That's the part I can't get. >:(
I don't see why it would lose the action given that it keeps literally everything in the URL after the bbs/ part...
The site these rules came from work correctly, I can only assume you're doing something weird about it - because it's not like I have enough information to debug this, like, say actual examples of where these things end up (because details actually matter). This of course assumes the edits to the domains etc. were made correctly because things like escaping matter here.
.htaccess
RewriteCond %{HTTP_HOST} !^www\.busconversions\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/bbs/?(.*) https://www.busconversionmagazine.com/forum/$1 [L,R,NE]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.busconversionmagazine.com/$1 [R=301,L]
#RewriteEngine on
#RewriteBase /
#RewriteCond %{HTTP_HOST} busconversions.com [NC]
#RewriteRule ^(.*)$ #https://www.busconversionmagazine.com/forum/index.php [R=301,NC]
Old link - https://www.busconversions.com/bbs/index.php?action=printpage;topic=364.0
New link - https://www.busconversionmagazine.com/forum/index.php?action=printpage;topic=364.0
How about you take out the chunk of code at the bottom that is performing a redirect without keeping the query string? You know, your original code that didn't work...
Hmm, it's commented out, isn't it. Will give it a try .......
Nope, try the links yourself.