Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I was running a website on a folder (www.example.com/folder). The new version of the website is live and runs on the root folder.

How should I redirect users who visit the website using the old URLs (either because they bookmarked it or through search engines)?

And in the long term, can I 'clean' the search engines results by removing the old links that show up?

share|improve this question
    
Do you have many pages? The best situation is probably going to be to redirect all of them if it is feasible as search engines will redirect and you will keep any link juice gained in the past –  Vince Pettit Jul 12 '12 at 15:27

2 Answers 2

If you use Apache you could use ModRewrite. Just put this in your .htaccess file in your root directory:

RewriteEngine On
RewriteRule ^/?folder/(.*)$ $1 [NE,R]
share|improve this answer
    
Thanks, I'm using drupal for this new website and obviously it has its own htaccess file. The problem is that instead of redirecting visitors to the front page it displays a page not found error message and that can be confusing for users. Is there a way to just redirect visitors to the new front page ? Thanks again –  amstram Jul 12 '12 at 14:57
    
You can add it to Drupal's htaccess file. You should have a look at this as well: templatemonster.com/help/… –  0xJoKe Jul 13 '12 at 6:25

You can use a 301 redirect in your htaccess which is the most appropriate to denote that something has moved (mostly search engine wise).

Just put a line like this in the drupal .htaccess or even create a separate .htaccess in the folder you user (if you still have it)

    redirect 301 /your_folder http://www.yourdomain.com/

What I usually do with drupal is have it in a subfolder and when I am ready to move it to the main domain I just create an .htaccess file in the root directory with rewriting and never move the actual files. I have found that this is more convenient especially when wanting to change the main domain content fast (say restore from a backup, without messing with existing files, create a new dir and change .htaccess to point to that).

my .htaccess looks like:

    Options -Indexes
    Options +FollowSymLinks

    RewriteEngine on

    # Redirect all user to WWW
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    # Serve Drupal 7 from sub directory in web root
    RewriteRule ^$ my_folder/index.php [L]
    RewriteCond %{DOCUMENT_ROOT}/my_folder%{REQUEST_URI} -f
    RewriteRule .* my_folder/$0 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* my_folder/index.php?q=$0 [QSA]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.