.htaccess help

Discussion in 'Site & Server Administration' started by Bhuntay, Sep 10, 2008.

  1. #1
    Bhuntay, Sep 10, 2008 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    Maybe try something like this:

    
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^secured(.*) https://www.yoursite.com/secured$1 [R,L]
    
    Code (markup):
     
    pr0t0n, Sep 10, 2008 IP
  3. mfwl

    mfwl Well-Known Member

    Messages:
    307
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    135
    #3
    or you could use a simple redirect in cpanel. This will set it all up for you!
     
    mfwl, Sep 10, 2008 IP
  4. Bhuntay

    Bhuntay Banned

    Messages:
    837
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #4
    While trying to create through cpanel I am getting the following error please help me.

    Apache detected an error in the Rewrite config.

    Syntax error on line 4 of /home/username/public_html/.htaccess.GWRdjATPmJtzaqQlUxvdOB3ZnsKKD4Pm:
    RewriteCond> directive missing closing '>'

    Please try again.

    Anyway thanks a lot.
     
    Bhuntay, Sep 10, 2008 IP
  5. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #5
    hmm are you sure you have pasted that code correctly? Because it works perfectly fine when I test it on my site. Try manually to enter those lines in your .htaccess file instead of through cpanel. Open your .htaccess from your main html folder with any text editor (for example notepad) and paste those lines. If you already have "RewriteEngine On" in your .htaccess then skip that part and just paste those two lines I suggested.
     
    pr0t0n, Sep 11, 2008 IP
  6. mfwl

    mfwl Well-Known Member

    Messages:
    307
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    135
    #6
    Something is not right here... Do you use your ftp client to edit text files on the spot. It might help. CuteFTP is great for it but I know most will allow you to edit/view files without moving them from the server. This should stop any problems with text encoding that notepad can cause.

    I dont understand why you have a hash after your .htaccess file in the error message. Have you named the file correctly?

    Sorry if I'm teaching you to suck eggs!
     
    mfwl, Sep 12, 2008 IP
  7. hostingonweb

    hostingonweb Peon

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    The htaccess code provided by pr0t0n is correct. It should work.
     
    hostingonweb, Sep 12, 2008 IP
  8. Bhuntay

    Bhuntay Banned

    Messages:
    837
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Oh My mistake :D it was .htaccess.txt :p Sorry :D It's not fixed :) Thank You
     
    Bhuntay, Sep 13, 2008 IP
  9. bouncer69

    bouncer69 Peon

    Messages:
    978
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    0
    #9
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.mysite.com$
    RewriteRule ^secured/?$ "https\:\/\/www\.mysite\.com\/secured" [R=301,L]
     
    bouncer69, Sep 13, 2008 IP
  10. Shinoda

    Shinoda Peon

    Messages:
    39
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #10
    hey eveyone seems to know something here, how can we rewrite from "root/forums/anyurls" to "root/anyurls"
    no-one knows this!
     
    Shinoda, Sep 13, 2008 IP
  11. ASTURIAS

    ASTURIAS Member

    Messages:
    239
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #11
    Make the index a PHP file and use this code instead:

    <?php
    header("Location: https://www.mysite.com/secured");
    ?>
     
    ASTURIAS, Sep 13, 2008 IP