create alias with .htaccess

Discussion in 'Apache' started by dvlad, Dec 26, 2011.

  1. #1
    Hello,

    I'm a complete noob in apache configuration, so please explain stuff as for the inocent mind :)

    I'm trying to create aliases for my sites files, for example:
    i want to redirect www.mysite.com/contact_new.html to www.mysite.com/contact .

    How do i do this? I read on the web that it can, very easely, be used "Alias /contact /contact_new.html" but it is bot available to use in .htaccess file.

    So where can i use it? (I don't own the server), or if this is out my hands, how can i do this with rewrite_mod ?

    Note: i have read different explanation on the web regarding this, but they didn't make any sense for me. So if you can, please just write the code that I can paste in my .htaccess file (regarding my example) , and then i will adapt it for other stuff.

    thank you!
     
    dvlad, Dec 26, 2011 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    If you want to have just a simple 301 redirection then you can try adding this to your .htaccess :
    
    redirect 301 /contact_new.html http://www.mysite.com/contact/
    
    Code (markup):
    or you can do it like this:
    
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^contact_new.html$ /contact/ [L]
    
    Code (markup):
    I hope this helps. Cheers!
     
    pr0t0n, Dec 26, 2011 IP
  3. dvlad

    dvlad Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you!

    I realized that I wrote it the other way around, but i finally got it working like this:

    RewriteRule ^contact$ /contact_new.html [L]

    Thanks again! Cheers!
     
    dvlad, Dec 27, 2011 IP