| :: |
| Author |
Message |
rochdalemark
Joined: 18 Feb 2007 Posts: 5
|
Posted: Sun Feb 18, 2007 8:11 pm Post subject: rewrite an entire directory to a single filename |
|
|
I have changed my site around and would like to put in my htaccess something that will rewrite all my old files in a particular directory i.e root/old/ and point them to browse.php in the root so that all inbound links to my site will be retained.
Any help would be much appreciated. thanks |
|
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14403
|
Posted: Mon Feb 19, 2007 7:10 pm Post subject: Re: rewrite an entire directory to a single filename |
|
|
And welcome
How about :
| Code: | RewriteEngine on
RewriteBase /
RewriteRule ^old/$ /browse.php [R=301,L] |
And please note that it's not the best thing to http 301 redirect too many urls to a single one.
If your urls just changed this way :
from example.com/old/page.html to example.com/page.html
you can use the following instead :
| Code: | RewriteEngine on
RewriteBase /
RewriteRule ^old/(.*)$ /$1 [QSA,L,R=301] |
It would http 301 redirect example.com/old/*.* to example.com/*.* and is a far better thing to do if you only got rid of the folder (all url still exist, but at the root level).
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
rochdalemark
Joined: 18 Feb 2007 Posts: 5
|
Posted: Mon Feb 19, 2007 7:33 pm Post subject: Re: rewrite an entire directory to a single filename |
|
|
| Quote: | PostPosted: Mon Feb 19, 2007 7:10 pm Post subject: Re: rewrite an entire directory to a single filename
And welcome Very Happy
How about :
Code:
RewriteEngine on
RewriteBase /
RewriteRule ^old/$ /browse.php [R=301,L]
And please note that it's not the best thing to http 301 redirect too many urls to a single one. |
Why is that?
P.S thanks for the reply |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14403
|
Posted: Mon Feb 19, 2007 10:20 pm Post subject: Re: rewrite an entire directory to a single filename |
|
|
well, it's just that if you previously had thousands of different urls in the old/ folder and you redirect them all to a single one, it's possible that some SE will penalize you website for some time.
I have no really theory about this besides the fact it can look like your site going a lot smaller very fast. . It's very different than redirecting many url to new urls, each url being redirected to it's new location, this works very well.
It's something I observed in several occasions, with Google mostly.
So I'd think about it twice before I'd redirect many urls to one. Unless content really disappeared.
So if the content of the old/ folder does still exist, there may be a way to redirect each url to it's new location which is what the second piece of code would do in case the script names and url standards stayed the same in the new folder structure.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
rochdalemark
Joined: 18 Feb 2007 Posts: 5
|
Posted: Mon Feb 19, 2007 11:05 pm Post subject: Re: rewrite an entire directory to a single filename |
|
|
Ah right I see what you mean.
Maybe its best to keep checking my logs on my site and find out which 404 errors are being generated. then do a rewrite for those urls only. As those will be the ones that have inbound links. |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14403
|
|
| Back to top |
|
 |
rochdalemark
Joined: 18 Feb 2007 Posts: 5
|
Posted: Tue Feb 20, 2007 12:21 pm Post subject: Re: rewrite an entire directory to a single filename |
|
|
| theres nothing similar about the page names between old and new. I used to have a xoops portal running on there with various info modules but shut it down a while ago now, But I have just opened up an e-commerce store on the same url but based on the same topic/theme. It just seemed a shame to me that I had inbound links for things based on the same topic but not landing on any page to pass PR. I was trying to think of a way to utilize those links by rewiting them to pages i do have. |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14403
|
Posted: Tue Feb 20, 2007 1:13 pm Post subject: Re: rewrite an entire directory to a single filename |
|
|
Well, in this case, redirecting means some works.
If you had kept the same script, it would have been very easy.
Besides, if the old links have been off for a while, there is no real interest to work on a per case redirection.
SE should have acknowledged about the fact the web site changed.
So I guess the massive redirect to one single file is the clue here, you won't loose all the older inbound links weight on PR, and it should not be a real problem since it will only concern backlinks (SE should not be listing old url in the old folder still, if you shut it down a while ago).
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
rochdalemark
Joined: 18 Feb 2007 Posts: 5
|
Posted: Tue Feb 20, 2007 3:23 pm Post subject: Re: rewrite an entire directory to a single filename |
|
|
| I agree that the old urls wont be listed in the SE's any longer, but there are still hundreds of links out there that have deep links pointing to my old site still. Surely the SE's still follow those links to my site and find 404's and. This being the case, those old links can still be utilised surely, if the SE then finds a page when it follows a link. |
|
|
| Back to top |
|
 |
|
|