SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    htaccess redirect

    how redirect old link witch htaccess

    old link exampel www.domain.com/index.php?menu=solution to new link www.domain.com/about



    (because change web page to new )

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    npc,

    Unless you write a specific RewriteCond/RewriteRule block, you just can't get there with the example provided as your "specification."

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2008
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    redirect 301 /index.php?menu=solution http://www.domain.com/about

    just add that to your .htaccess file and should also pass on any page rank after a few weeks.

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    floob,

    Sorry, Apache.org's "Syntax: Redirect [status] URL-path URL" indicates that the query string is NOT a part of the test for this redirection so it can't be used.

    Therefore, unless npc used mod_rewrite's more powerful scripting (RewriteCond and RewriteRule in a block statement), "ya can't get there from here."

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm make with php

    switch ($_GET['menu']) {
    case 'solution':
    header("Status: 301");
    header("Location: http://{$_SERVER['SERVER_NAME']}/about");
    break;
    ...

    How this way?

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    npc,

    Using mod_rewrite in your .htaccess:
    Code:
    RewriteEngine on
    RewriteCond %{QUERY STRING} ^menu=solution$
    RewriteRule ^index\.php$ about/ [L]
    Please take the time to read the tutorial article linked in my signature if you want to learn WHY this would work.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  7. #7
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thx for help .

  8. #8
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Old url must be redirected to new url with htaccess / mod_rewrite.

    Old url : example.com/page?ref=someparam1&from=anywhere
    New url: example.com/newpage/someparam1/anywhere

    I tried with this but it does not work!



    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^page?ref=(.*)&from=(.*)$ newpage/$1/$2 [R=301,QSA,L]


    What is wrong?
    Last edited by dklynn; Jun 5, 2009 at 02:20. Reason: Don't double post - I removed your new thread.

  9. #9
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    w2c,

    What's wrong is your attempt to access the query string in a RewriteRule (which can only access the {REQUEST_URI} variable.

    Have a look at my signature's tutorial.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •