Solved

301 Redirects via .htaccess question

Posted on 2008-10-31
5
214 Views
Last Modified: 2012-05-05
I hoping someone can help this Linux newbie understand a problem I need to solve with 301 redirects. I've enabled the AllowOverride Switch in httpd.conf and created the appropriate .htaccess file. I have 2 old pages I wish to redirect to specific new pages. Then, I'd like all the remaining broken links to redirect to the main default page.

What is the best way to accomplish the third redirect shown below. I tried using similar syntax but it didn't seem to work.See code snippet below

Redirect 301 /pages/locations.html      http://www.website.com/storelocator.htm 

Redirect 301 /pages/about.html          http://www.website.com/about.htm

Redirect 301 /pages/ALLOTHERLINKS       http://www.website.com/

Open in new window

0
Comment
Question by:Spiderkingdemon
5 Comments
 
LVL 1

Expert Comment

by:frandshansen
ID: 22853895
Maybe if I were you I'd set up an 404 redirect instead.

You can use the directive ErrorDocument

ErrorDocument 404 http://yoursite.com/
0
 
LVL 27

Accepted Solution

by:
caterham_www earned 125 total points
ID: 22856440
-> RedirectMatch

RedirectMatch 301 ^/pages/ http://www.website.com/

matches /pages/foo.

An ErrorDocument 404 with a http://... will generate a 302 redirect only.
0
 
LVL 12

Expert Comment

by:ShaneJones
ID: 22856832
Do it this way should work fine

Redirect 301 /pages/locations.html "http://www.website.com/storelocator.htm"

Redirect 301 /pages/about.html "http://www.website.com/about.htm"

Redirect 301 /pages/ALLOTHERLINKS "http://www.website.com/"

Open in new window

0
 

Author Closing Comment

by:Spiderkingdemon
ID: 31512154
Thank you! This was the answer.
0
 

Author Comment

by:Spiderkingdemon
ID: 22857053
Shane -- thanks for you post but I tried that and it did not work. Caterham-www's answer worked perfect.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now