How to redirect to permanent urls..?

Discussion in 'PHP' started by Deepak_Kotian, Nov 15, 2012.

  1. #1
    I have a website which has additional urls i have to redirect that urls to a permanent url.. How can i do that..? Please explain..
     
    Deepak_Kotian, Nov 15, 2012 IP
  2. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #2
    Use your .htaccess for this, see: corz.org/serv/tricks/htaccess2.php for some syntax tutorials.
    Most if not all of the .htaccess syntax is in regular expression so if your familiar with the logic it shouldn't be that hard to master.



    example of redirecting the www to non-www without specifying the domain name:

    
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    
    Code (markup):






    ROOFIS:cool:
     
    ROOFIS, Nov 15, 2012 IP