SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot Tikila's Avatar
    Join Date
    Jun 2007
    Location
    Toronto
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to redirect a php url with query parameters to a static page

    Hi everybody,
    Hope someone can help me out with this.
    I just mod-rewritten some of my urls to static-looking ones.Now the problem is there are lots of inbound links out there that still pointing to these pages with the old dynamic query strings.
    I need to 301 redirect those dynamic query strings to the homepage. I tried:

    redirect 301 /DynamicFolder/articles.php http://www.homepage.com

    so:

    articles.php?id=3
    is now redirected as
    http://www.homepage.com/?id=3 (I want to get rid of the ?id=3 part)

    By the way,this also redirect the newly static-looking pages to the same above destination
    so,
    articles1-3.htm
    is now redirected as
    http://www.homepage.com/?id=3

    Any help would be much appreciated

  2. #2
    SitePoint Zealot MikeDVB's Avatar
    Join Date
    Mar 2008
    Location
    Indiana, USA
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Tikila View Post
    Hi everybody,
    Hope someone can help me out with this.
    I just mod-rewritten some of my urls to static-looking ones.Now the problem is there are lots of inbound links out there that still pointing to these pages with the old dynamic query strings.
    I need to 301 redirect those dynamic query strings to the homepage. I tried:

    redirect 301 /DynamicFolder/articles.php http://www.homepage.com

    so:

    articles.php?id=3
    is now redirected as
    http://www.homepage.com/?id=3 (I want to get rid of the ?id=3 part)

    By the way,this also redirect the newly static-looking pages to the same above destination
    so,
    articles1-3.htm
    is now redirected as
    http://www.homepage.com/?id=3

    Any help would be much appreciated
    Just drop the $1 (or whatever you have) off of the rewrite rule.

    If you can post the rule you are using up I can modify it for you.
    Michael Denney - MDDHosting, LLC - Hosting over 8,500 domains!
    http://www.mddhosting.com/ - Celebrating 3 years in business!
    Serious Internet Solutions, LLC. - Quality Unmanaged VPS
    SeriousVPS - http://www.seriousvps.com

  3. #3
    SitePoint Zealot Tikila's Avatar
    Join Date
    Jun 2007
    Location
    Toronto
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you MikeDVB
    Just to clarify
    I want to intercept any dynamic link and 301 redirect it to the homepage(so google drops them from its index indefinitely)
    But the dynamic links do exist in my directory,I just want them requested as static.So if i redirect them,both versions(dynamic and static)
    will be directed to the homepage(but i dont want the static version to be redirected to the homepage)

    Here's the rule:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule articles(.*)-(.*)-(.*)-(.*)\.htm$ /DynamicFolder/articles.php?id=$1&cat_name=$2&tag=$3&type=$4


    http://www.homepage.com/articles$id-$category-$label-$type_name.htm

  4. #4
    SitePoint Zealot MikeDVB's Avatar
    Join Date
    Mar 2008
    Location
    Indiana, USA
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Tikila View Post
    Thank you MikeDVB
    Just to clarify
    I want to intercept any dynamic link and 301 redirect it to the homepage(so google drops them from its index indefinitely)
    But the dynamic links do exist in my directory,I just want them requested as static.So if i redirect them,both versions(dynamic and static)
    will be directed to the homepage(but i dont want the static version to be redirected to the homepage)

    Here's the rule:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule articles(.*)-(.*)-(.*)-(.*)\.htm$ /DynamicFolder/articles.php?id=$1&cat_name=$2&tag=$3&type=$4


    http://www.homepage.com/articles$id-$category-$label-$type_name.htm
    I'm not seeing a rule that redirects from your dynamic URL to a static one but just one that masks the dynamic under static.

    You will need a secondary rule to rewrite off the parameters.
    Michael Denney - MDDHosting, LLC - Hosting over 8,500 domains!
    http://www.mddhosting.com/ - Celebrating 3 years in business!
    Serious Internet Solutions, LLC. - Quality Unmanaged VPS
    SeriousVPS - http://www.seriousvps.com

  5. #5
    SitePoint Zealot Tikila's Avatar
    Join Date
    Jun 2007
    Location
    Toronto
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry,it's the one above,here:


    redirect 301 /DynamicFolder/articles.php http://www.homepage.com

    I still need the parameters on the underlying dynamic urls in my site(so the site functions properly).I just want to remove them from links that are coming from outside my site and then redirect them(those external links) to the homepage so search engines drop them from their indexes.

  6. #6
    SitePoint Zealot MikeDVB's Avatar
    Join Date
    Mar 2008
    Location
    Indiana, USA
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Tikila View Post
    Sorry,it's the one above,here:


    redirect 301 /DynamicFolder/articles.php http://www.homepage.com

    I still need the parameters on the underlying dynamic urls in my site.I just want to remove them from links that coming from outside my site and then redirect them to the homepage so search engines drop them from their indexes
    You may want to try something like:
    Code:
    redirect 301 /DynamicFolder/articles.php(.*) http://www.homepage.com
    or
    Code:
    redirect 301 /DynamicFolder/articles.php ^http://www.homepage.com$
    I'm not sure, I've never seen it keep the parameters on in a re-write unless you specifically wrote it to do so. I'm certainly not a mod_rewrite guru so I'm just trying to help
    Michael Denney - MDDHosting, LLC - Hosting over 8,500 domains!
    http://www.mddhosting.com/ - Celebrating 3 years in business!
    Serious Internet Solutions, LLC. - Quality Unmanaged VPS
    SeriousVPS - http://www.seriousvps.com

  7. #7
    SitePoint Zealot Tikila's Avatar
    Join Date
    Jun 2007
    Location
    Toronto
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks mike
    It would be awsome if i can redirect any incoming dynamic url to its static-equivalent one instead of to the homepage.
    Am not a mod-rewrite guru either,Otherwise I would've combined both rules(One to mask and one to redirect to the masked so that whatever the user types it would lead them to the static version anyways)
    The only other way i can think of is to get the referrer and if outside my domain redirect it to the homepage
    Thank you for your time to help

  8. #8
    SitePoint Zealot MikeDVB's Avatar
    Join Date
    Mar 2008
    Location
    Indiana, USA
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Tikila View Post
    Thanks mike
    It would be awsome if i can redirect any incoming dynamic url to its static-equivalent one instead of to the homepage.
    Am not a mod-rewrite guru either,Otherwise I would've combined both rules(One to mask and one to redirect to the masked so that whatever the user types it would lead them to the static version anyways)
    Thank you for your time to help
    It is doable, I'll ask some people I know that are better at it than me - hopefully I can come back with something useful.

    If you want to PM me the details of the URLs you want to rewrite from and to I will see what I can do.
    Michael Denney - MDDHosting, LLC - Hosting over 8,500 domains!
    http://www.mddhosting.com/ - Celebrating 3 years in business!
    Serious Internet Solutions, LLC. - Quality Unmanaged VPS
    SeriousVPS - http://www.seriousvps.com

  9. #9
    SitePoint Zealot Tikila's Avatar
    Join Date
    Jun 2007
    Location
    Toronto
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MikeDVB View Post
    It is doable, I'll ask some people I know that are better at it than me - hopefully I can come back with something useful.

    If you want to PM me the details of the URLs you want to rewrite from and to I will see what I can do.


    details PMed ,thanks mike

  10. #10
    SitePoint Zealot MikeDVB's Avatar
    Join Date
    Mar 2008
    Location
    Indiana, USA
    Posts
    174
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Tikila View Post
    details PMed ,thanks mike
    Got it. Can't make any promises but I'll do my best
    Michael Denney - MDDHosting, LLC - Hosting over 8,500 domains!
    http://www.mddhosting.com/ - Celebrating 3 years in business!
    Serious Internet Solutions, LLC. - Quality Unmanaged VPS
    SeriousVPS - http://www.seriousvps.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •