| |
| |
|
|
|
|
| |
|
| |
|
| :: |
| Author |
Message |
ultimatehandyman PR2

Joined: 15 Mar 2007 Posts: 209
|
Posted: Sat May 05, 2007 11:49 am Post subject: Moving indexed pages |
|
|
When I first made my site I knew absolutely nothing about websites or SEO and so I just made pages for my site and uploaded them to the sites root folder, now I realise that I should of created directories to put the files into as it would make the site more tidy and could also help with SEO as I can get important keywords into the url. So for example if I have a page about fitting taps that was named fitting_taps.htm, I could place this in directories such as diy/plumbing/fitting_taps.htm and this would help with SEO as it would possibly show up on the search engines when someone searches for diy tap fitting or plumbing tap fitting etc.
I now want to start to create some directories and move the pages from the main root folder into the relevent directories on the site.
Is the best way to acheive this through a 301 redirect, by placing the code in the .htaccess file?
I can't remember the code to do this but I have seen it on here somewhere
So If I have the right idea here, I copy the file to the new directory and add the code to the .htaccess file which will redirect from the original page- fitting_taps.htm and redirect them to diy/plumbing/fitting_taps.htm and then after a few weeks I delete the original file fitting_taps.htm, is this the correct way to do this?
Thanks in advance
chez |
|
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14131
|
Posted: Sun May 06, 2007 10:35 am Post subject: Re: Moving indexed pages |
|
|
You're right, folder structure can help out a bit, but in the same time, you do not really want a web site with a thousand folder with just one
page in them.
Folders can be good to help out categorizing content, for both bots and human, but you need content to categorize, at least some, and better if you continue to add articles.
About redirections, that's the principle, but, you cannot really add thousand of rewriterules in your .htaccess.
For few it's ok to add things like :
| Code: | | RewriteRule ^page_title\.html$ /cat_folder/page_title.xml [L, R=301] |
at the very end of your .htaccess for example.
But if you really have many it's handier to deal with a script to redirect them.
The principle would be to redirect any html file that seems to first not exist top a script that will either redirect, if the file does exist but went moved or a 404 when it really does not exist.
At the very end of your .htaccess :
| Code: | RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-z0-9_-]+)\.html$ /redir.php?uri=$1 [QSA,L] |
and redir.php would be something like :
| Code: | <?php
// Config
$url = "http://www.example.com/"; // Your domain's root url, with trailing slash
// The pages array, with old vs new titles, notice the key does not use .html, but the value does.
$pages_array = array( 'page_title1' => 'folder1/page_title1.html,
'page_title2' => 'folder2/page_title3.html,
);
$uri = (isset($_GET['uri'])) ? trim(htmlspecialchars(strtolower(($_GET['uri']))) : '';
if ( !empty($uri) && !empty($pages_array[$uri]) ) { // the page exists
$url .= trim($pages_array[$uri]);
header("HTTP/1.1 301 Moved Permanently", FALSE , 301);
header("Location:" . $url);
exit();
} else { // it's a 404
$message = "the message to be displayed for 404s, can have links to your index in it and html";
header("HTTP/1.1 404 Not Found");
header ('Content-Type: text/html');
echo '<html><head><title>' . $header_msg . '</title><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head><body><br/><pre>' . $message . '</pre></body></html>';
exit();
}
?> |
This is handy as well because you can take the occasion to rename some files as well as to move them this way.
You just need to populate the $pages_array :
| Code: |
$pages_array = array( 'page_title1' => 'folder1/page_title1.html',
'page_title2' => 'folder2/page_title3.html',
); |
As you can see with this, page_title1.html => folder1/page_title1.html and page_title2.html => folder2/page_title3.html
The 404 is here important because this script will handle all possible .html files at the server root level that does not exist, the one you'd like to redirect (since they have moved, they do not exist at the root level) and the real 404s, so you want to output 404 for the real 404 for SE's to continue to find their way in your site properly.
 |
_________________ 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 |
|
 |
ultimatehandyman PR2

Joined: 15 Mar 2007 Posts: 209
|
Posted: Sun May 06, 2007 10:49 am Post subject: Re: Moving indexed pages |
|
|
Thanks very much for that
I will test it out in a few weeks, I am currently working on a new section for the site (which is in the correct folders).
That would be a great solution to my problem!
Thanks
chez |
|
|
| Back to top |
|
 |
ultimatehandyman PR2

Joined: 15 Mar 2007 Posts: 209
|
Posted: Fri May 11, 2007 2:08 pm Post subject: Re: Moving indexed pages |
|
|
I have been thinking about this and I think the best option for me is just to move a few pages that are indexed and have page rank.
I'm struggling at the moment as my desktop keeps crashing and my laptop has problems as well and so I am really struggling getting online at the moment
So Hopefully It will be ok if I move the pages and add the code to the .htaccess file, there will probably only be about ten pages that I will move and use a 301 redirect? |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14131
|
|
| Back to top |
|
 |
ultimatehandyman PR2

Joined: 15 Mar 2007 Posts: 209
|
Posted: Fri May 11, 2007 5:16 pm Post subject: Re: Moving indexed pages |
|
|
I'll try the php solution first then
I'm on girlfriends pc now, but will try it in the next few weeks.
Thanks dcz |
|
|
| Back to top |
|
 |
|
|
| Navigation |
Similar Topics |
|
|
|
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |