How to redirect this?

Discussion in 'Apache' started by JEET, Nov 23, 2009.

  1. #1
    Hi,
    My .htaccess has the following:

    RewriteRule ^H_(.*)\.html$ test.php?a=$1 [L]


    I want to redirect
    domain.com/test.php?a=done to:
    domain.com/H_done.html
    and still show the data of test.php?a=done
    but the browser now shows the static URL instead of the regular one (which was typed)

    Can I do this?
    Thanks :)
     
    JEET, Nov 23, 2009 IP
  2. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    So you want to force a redirect from:

    domain.com/test.php?a=done

    to:

    domain.com/H_done.html

    And still have:

    domain.com/H_done.html

    Load:

    domain.com/test.php?a=done ?

    If so, try this htaccess file.
     
    chadsmith, Nov 23, 2009 IP
  3. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #3
    Hi,
    That page above gave me this code:
    RewriteRule ^H_done\.html$ /test.php?a=done [L]
    I think this is what I already have.
    The problem with this is that if I type the ugly URL in browser, it does not redirect to pretty URL. Instead it loads the page.
    You understood my question right. I want it to redirect to pretty URL and still show the same data which the ugly URL loads.

    Can you give me the htaccess code? :)
    Thanks :)
     
    JEET, Nov 23, 2009 IP
  4. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #4
    Hi,
    Can anyone give me a htaccess code for this redirection?
    Thanks :)
     
    JEET, Nov 24, 2009 IP
  5. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It should have given you:

    Options -Multiviews
    
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{ENV:REDIRECT_STATUS} 200
    RewriteRule .* - [L]
    
    # Redirect old pages
    RewriteCond %{QUERY_STRING} ^a=([a-z]+)$
    RewriteRule ^test\.php$ /H_%1.html? [R=301,L]
    
    # Specify search friendly URLs
    RewriteRule ^H_([a-z]+)\.html$ /test.php?a=$1 [L]
    
    # Generated for free at SearchFriendlyURLs.com
    Code (markup):
    This part is what redirects from the old addresses to the new:

    # Redirect old pages
    RewriteCond %{QUERY_STRING} ^a=([a-z]+)$
    RewriteRule ^test\.php$ /H_%1.html? [R=301,L]
    Code (markup):
     
    chadsmith, Nov 28, 2009 IP
  6. bhagwant.banger

    bhagwant.banger Active Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    60
    #6
    I m new here but I one of above syntaxes will redirect they are only simple rewrite rules nothing more than that
     
    bhagwant.banger, Nov 28, 2009 IP
  7. sallysmith

    sallysmith Peon

    Messages:
    95
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Helo,
    the topic is 'how to redirect this' that's why I will right it here. I have a small problem with making redirect from really strange page: examplesite.com/.html to examplesite.com/ - usual redirect 301 doesn't work. Are pages like that should be redirected in a different way?
     
    sallysmith, Dec 16, 2009 IP