Redirect help

Discussion in 'Apache' started by ickle, Dec 6, 2011.

  1. #1
    Hi Guys,

    I'm having trouble creating a 301 redirect for the following type of URL:

    mysite.com/?s=somepage
    
    to
    
    mysite.com/pages/newpage
    PHP:
    It doesn't seem to work for something like:

    redirect 301 /?s=somepage http://www.mysite.com/pages/newpage
    PHP:
    Any help would be appreciated :D

    Thanks
     
    ickle, Dec 6, 2011 IP
  2. BarrettNetworks

    BarrettNetworks Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Untested but try this with php.

    
    <?
        Header( "HTTP/1.1 301 Moved Permanently" ); 
        Header( "Location: http://www.new-url.com" ); 
    ?>
    
    Code (markup):
    Could also do it with .htacess

    
    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^domain.com [nc]
    rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
    
    Code (markup):
    Hope this helps
     
    BarrettNetworks, Dec 10, 2011 IP
  3. stevemack

    stevemack Peon

    Messages:
    136
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    as above mate said, it can done through htaccess as well as PHP redirection also.
     
    stevemack, Dec 14, 2011 IP