homepage Welcome to WebmasterWorld Guest from 54.226.161.112
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque & physics

Webmaster General Forum

    
Mass 301 redirect - help required please
glennk




msg:4029555
 9:06 am on Nov 22, 2009 (gmt 0)

If this is posted in the wrong section could the moderators please move it and leave a redirect or something to alert me of where to find it on my return.

Hi Guys,

Im currently on with a project to simplify my website and bring all my content into 1 database. The downside of this is that quite a few of my urls will change and therefore I need a 301 redirect for this. This is the type of url I am trying to redirect

mydomain.co.uk/north-east-fishing-news/a-bass-wins-redcar-open/

will be redirected to

mydomain.co.uk/a-bass-wins-redcar-open/

As you can see, the sub folder "north-east-fishing-news" will be removed from the url and all post files will now reside in the root. There are roughly 1000 similar urls that need redirecting in the same way. Is there a simple piece of code I can put in my htacess to do this please ?

 

phranque




msg:4029578
 11:31 am on Nov 22, 2009 (gmt 0)

i haven't tested it but this might work:
RedirectMatch permanent ^(([^/]+/)*)([^/]*)$ http://example.co.uk/$3

glennk




msg:4029586
 12:07 pm on Nov 22, 2009 (gmt 0)

I added your code to the htaccess in my root. Its Not currently working. I am not too clued up on htaccess. I am wondering why it doesnt work. Could your suggested code be interfered with by other already existing code in my htaccess. Or could it be that the htaccess in the subfolder is overruling the htaccess in my root ?

phranque




msg:4029596
 1:17 pm on Nov 22, 2009 (gmt 0)

yes it could be affected by all of the above and by what is in your apache config file and whether mod_alias is running on your server.
and assuming it's an apache server.

glennk




msg:4029601
 1:31 pm on Nov 22, 2009 (gmt 0)

What is the best way to move forward with this type of thing?

icedowl




msg:4029628
 3:01 pm on Nov 22, 2009 (gmt 0)

glennk,
Not too long ago I did the same thing that you want to do. This is what worked for me:

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^folder(/(.*))?$ /$2 [R=301,L]

Change folder in the above example to the name of your unwanted folder.

glennk




msg:4029646
 4:03 pm on Nov 22, 2009 (gmt 0)

Thanks for posting icedowl. Where does this code go ? Does it go in .htaccess in the root or in the folder ?

Also do I add it into the htaccess with the code thats already in there or do I add it over the exisitng code. And does it work with permalinks enabled ?

icedowl




msg:4029656
 4:37 pm on Nov 22, 2009 (gmt 0)

I have mine as the very first thing in my htaccess file, which is in the root (public_html).

I'm not sure about it working with permalinks or your other questions. Maybe someone else knows or you could just try it and see what happens.

glennk




msg:4029750
 8:21 pm on Nov 22, 2009 (gmt 0)

you wont believe it.

I added that line and got an internal error. I took the line out and the internal error persists. I cant work it out as I never changed anything else.

Ive had to disable the htaccess for the time being. Ive contacted my hosts to see what they make of it.

Very strange indeed.

phranque




msg:4029809
 11:44 pm on Nov 22, 2009 (gmt 0)

you must clear your cache before testing any changes.
the order of things is important.
you should definitely be using a tool that will show you request and response headers.
are you doing any redirects in the apache config file?
are you getting a single 301 response or is there a chain of redirects?
are you doing any internal rewrites?
i would suggest you post an exemplified version of your .htaccess file in the Apache forum with a description of the response/redirect chain you get from the server.

glennk




msg:4030010
 12:34 pm on Nov 23, 2009 (gmt 0)

Thanks Phranque. I will do that.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved