#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Htaccess 301 redirect help


    Hi,
    I'm trying to redirect old urls of my old web site to new urls to my new web site.
    There ara several urls to redirect and I need to redirect them one to one.
    My old url is:
    Code:
    http://www.oldsite.com/index.php?page=old-address
    And the new url is:
    Code:
    http://www.newsite.com/new-adress
    I tried this;

    Code:
    RewriteEngine On
    RewriteBase /
    redirect 301 /index.php?page=old-address http://www.newsite.com/new-adress

    And this;
    Code:
    RewriteEngine On
    RewriteBase /
    redirect 301 /index.php%3Fpage=old-address http://www.newsite.com/new-adress

    but it didn't work. Do you have any idea to help me?

    Thanks.
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,995
    Rep Power
    9397
    Big swing, big miss.

    You can't use URL rewriting for it besides for the literal act of turning "new-adress" into "index.php?old-address". There's no regular expressions.

    Is this just a single thing? Only this one URL? Or are there more? Do they follow some pattern?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    Dear requinix,

    It's not only 1 url, there are too many but they do not have any pattern.
    I'm ready to write them one by one if I can learn how to.

    Thanks.



    Originally Posted by requinix
    Big swing, big miss.

    You can't use URL rewriting for it besides for the literal act of turning "new-adress" into "index.php?old-address". There's no regular expressions.

    Is this just a single thing? Only this one URL? Or are there more? Do they follow some pattern?
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,995
    Rep Power
    9397
    Do you have a mapping of these URLs somewhere? Anywhere at all? If not then you'll have to write it out.

    Take a look at RewriteMap. It'll let you manage the mappings easily and without flooding your .htaccess with tons of rules.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    Dear requinix,

    There are nearly 200 urls and there is no interaction or pattern.
    It's not really too hard for me to write them one by one if I know how can I do that.

    Thanks.



    Originally Posted by requinix
    Do you have a mapping of these URLs somewhere? Anywhere at all? If not then you'll have to write it out.

    Take a look at RewriteMap. It'll let you manage the mappings easily and without flooding your .htaccess with tons of rules.
  10. #6
  11. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1099
    [code=newsite.com/.htaccess]RewriteEngine On

    RewriteCond %{QUERY_STRING} page=old-address [NC]
    RewriteRule ^index\.php$ /new-address [R=301,L][/code]Repeat for each old-address to new-address.

    Comments on this post

    • aitken325i agrees
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.

IMN logo majestic logo threadwatch logo seochat tools logo