Forum Moderators: phranque

Message Too Old, No Replies

Redirect Folder, but not folder content

         

Ma2T

10:36 pm on Sep 24, 2006 (gmt 0)

10+ Year Member



Hey there,

Im trying to work out a redirect that will redirect a folder to another folder, but not redirect what is in that content.

Eg.

site.com/foldera/ redirect to - > site.com/new/foldera/
site.com/folderb/ redirect to - > site.com/new/folderb/

etc...

But NOT to redirect

site.com/foldera/anotherfolder/ ---- Do not redirect anywhere.

I am having trouble as the url above will have "new" added to the url in my example above.

I hope this is clear enough.

Any help would be much appreciated,
Cheers :)

Quadrille

11:23 pm on Sep 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I understand you correctly, what you seek to do is not possible.

The workaround is to 301 each file you want redirected individually, leaving others in place.

It does sound overcomplicated to me, and I'd think carefully if what you are planning to do really is the best solution to whatever the problem is.

Either way, if you,have a quality user-friendly 404 page, you should survive.

Ma2T

11:38 pm on Sep 24, 2006 (gmt 0)

10+ Year Member



Thanks for your reply Quadrille, I feared that might be the reply.

My site is a wordpress blog, and unfortinatly the way I have set it up, and the way wordpress works causes some problems.

I have different categories, all following a base folder, such as:

site.com/base/category/

but the articles for each category are:

site.com/category/article/ .... Note no Base in these urls.

Annoyingly, you can access the same categories without using the "Base" folder first, causing each category to have duplicate content in google, and also on this page the [page 2] etc links are broken.

A simple solution would be to redirect the url for the categories without the base url, to the category with the base url, but of course without effecting the articles.

Edit: As im sure you know, wordpress categories / articles are not real files / folders, just fancy peralinks.

[edited by: Ma2T at 11:39 pm (utc) on Sep. 24, 2006]

Ma2T

11:46 pm on Sep 24, 2006 (gmt 0)

10+ Year Member



I have just had an interesting idea.

I just made a folder on the ftp, with the same name as one of my categories. When I goto this url, the folder contents shows, and the articles still work.

so now,

site.com/category1/ (shows folder - Good)
site.com/category1/article1/ (shows article - Good)
site.com/base/category1 (shows real category - Good)

As this appears to be working, I assume I could create an index file in this folder with a meta redirect to the category with the base url, the correct one)
Or maybe I could place some sort of .htaccess file in this folder to redirect. (But this may cause the articles to redirect also)

I hope I am making some sense and someone can follow me lol.

Any suggestions would be great,
Cheers

===== EDIT

I just read that meta redirects are not good, as many search engines do not read them.

If i create a file called index.php, and include the following code, it seems to do the trick.

<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: [site.com...]
exit();
?>

I will have to create about 20 of these, not the most efficient way of doing things, but i believe it will work.

Any mistakes in my logic? If there is something please let me know, if it is correct, also let me know please!

Many thanks for your help :)

[edited by: Ma2T at 11:57 pm (utc) on Sep. 24, 2006]