redirect in htaccess

Discussion in 'Apache' started by hurricane_sh, Oct 22, 2004.

  1. #1
    I changed the file extension of the whole site, is it possible to redirect the old URLs without listing all in htaccess?

    For example:
    redirect permanent file1.html http://www.domain.com/file1.php
    ...
    redirect permanent file100.html http://www.domain.com/file100.php


    Mod_rewrite seems not suitable because I want the Search Engines know the new files.

    Thanks!
     
    hurricane_sh, Oct 22, 2004 IP
  2. Solicitors Mortgages

    Solicitors Mortgages Well-Known Member

    Messages:
    2,217
    Likes Received:
    139
    Best Answers:
    0
    Trophy Points:
    103
    #2
    Its easier to create a custom 404 page that directs users just back to your home page.
    GEM
     
    Solicitors Mortgages, Oct 27, 2004 IP
  3. catasoft

    catasoft Member

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    But if the page has a high PR, wouldn't that just ruin it?
    404 on a PR4 page moves the PR to that page, not the one with the actual information one wants to show.
     
    catasoft, Jun 7, 2006 IP
  4. Xig

    Xig Peon

    Messages:
    75
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Mod rewrite and PHP can be useful. For example, using mod rewrite you can redirect all .html URLs to a single PHP script, which using server variables can return a redirect or display a suitable error message:

    "This page has been moved to http://domain.com/page.php"

    Would that be of use?
     
    Xig, Jun 7, 2006 IP
  5. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Quite right, you should redirect to the new page from the old page.

    I reckon he probably got it sorted by now though.:rolleyes:
     
    mad4, Jun 7, 2006 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    Did some one get bumped??!! :D But sine it hasn't been posted yet, and hurricane_sh was last actiave...today...


    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)\.php$ http://www.domain.com/$1.html [R=301,L]

    to redirect from .php to.html and the search engines will evenutally update the links and take the PR to the new URL.

    Something tells me there was no mod_rewrite/redirect pro here before I came along!! :D:D
     
    Nintendo, Jun 7, 2006 IP
    sarathy likes this.
  7. Xig

    Xig Peon

    Messages:
    75
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    An elegant solution! Thanks Nintendo .. I've learnt something today (even if I am hungover) :D
     
    Xig, Jun 7, 2006 IP