Avatar of colwhi99
colwhi99

asked on 

Assistance with code for 301 redirect

I have taken over the hosting of a new website and need to redirect the existing pages that may be in Google or saved by users as the directory structure has changed:

Old format: http://www.domainname.com/cgi-bin/forum/cgi-bin/yabb2/YaBB..pl?num=1234567

New format: http://www.domainname.com/cgi-bin/forum/YaBB.pl?num=1234567

I have tried:

 Redirect /cgi-bin/forum/cgi-bin/yabb2/YaBB.pl http://www.domainname.com/cgi-bin/forum/YaBB.pl

But it fails with a 404 error.

Could someone help with exact .htaccess file syntax I need to get it working? Rewrite is supported.

Thanks.
Scripting LanguagesWeb ServersApache Web Server

Avatar of undefined
Last Comment
colwhi99
ASKER CERTIFIED SOLUTION
Avatar of MushyPea
MushyPea

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of colwhi99
colwhi99

ASKER

Hi MushyPea,

Yes you got it, I added the Rewrite Engine on and the old type links now work perfectly.

However I notice that when I link fron one of the 'new pages' in the http://www.domainname.com/cgi-bin/forum/YaBB.pl?num=1234567 format that the displayed url is the old
http://www.domainname.com/cgi-bin/forum/cgi-bin/yabb2/YaBB..pl?num=1234567 format.

Is that OK and how it's supposed to work, I expected that the new format would be the displayed url?

Thanks.
Avatar of MushyPea
MushyPea

Do you mean that the URL in the address bar doesn't change after the redirect?  Or something else?
Avatar of colwhi99
colwhi99

ASKER

Hi,

It's working fine, and your solution was spot on.

The additional confusion was due to the caching of the browser pages, once cleared it was fine.

thanks,

Colin.
Web Servers
Web Servers

A web server refers to the software that helps to deliver web content that can be accessed either through the Internet or through an intranet. The primary function of a web server is to store, process and deliver web pages to clients. The communication between client and server takes place using the Hypertext Transfer Protocol (HTTP). The most common use of web servers is to host websites, but there are other uses such as gaming, data storage, running enterprise applications, handling email, FTP, etc.

33K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo