Solved

301 Redirects via .htaccess question

Posted on 2008-10-31
5
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

696 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