Solved

301 Redirects via .htaccess question

Posted on 2008-10-31
5
223 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Multiple SSL sites on one IP? 3 41
erroer in installing php7.0.7 on an apache 2 machine 4 151
Best IDE for PHP starters 11 141
Apache error.log 19 72
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…

733 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