Issues with Redirection and HTACCESS

cableguysteve

Registered
Dec 29, 2020
3
1
3
Ontario, Canada
cPanel Access Level
Root Administrator
Good Day and Thanks for any assistance:

I have two url's:

https://my-site.com/view?id=1001554 - Old URL

https://my-site.ca/search-item.html?psid=1001554 - New URL

As you can see the site changes from .com to .ca and on the new URL there is a HTML page inserted into the URL.As well the ?id is changed to ?psid as well.

I have looked at many examples but there is none that has just the page in the new url. Could someone assist me in the .htaccess file and making this work.

Thanks

Steve Fulton, UE
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
5,552
708
313
cPanel Access Level
Root Administrator
Hey there! Those type of URLs indicate there is some application (Wordpress, Joomla, etc.) running on the site, so it might be better to see if the URLs can be fixed or adjusted directly in the app than to try and manipulate them with .htaccess.
 

cableguysteve

Registered
Dec 29, 2020
3
1
3
Ontario, Canada
cPanel Access Level
Root Administrator
Hi there

Thanks for the message, Unfortualty the old URL came from FoxPro and it is no longer available. The new URL is straight HTML. Is there anyway to resolve this? If not i am going to have to rewrite 1.9 million MYSQL lines to resolve.

Thanks

Steve
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
5,552
708
313
cPanel Access Level
Root Administrator
I don't claim to be a .htaccess wizard, but there likely isn't going to be one rule that will handle this at it may need to be a combination of things. What about something similar to the following?


 

wintech2003

Well-Known Member
PartnerNOC
Sep 15, 2010
103
28
78
Greece
cPanel Access Level
DataCenter Provider
Hello, if you put something like that in your .htaccess at my-site.com it should do what you want:
Code:
RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/view$
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^(.*)$ https://my-site.ca/search-item.html?psid=%1 [R=302,L]
 
  • Like
Reactions: cPRex