Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

How to use .htaccess

SrggamerSrggamer HardCore Gamer ✭✭✭

I feel like, asking this question because know one can explain this.

Because:

# For sites running on a port other than 80
RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^/(.*)         http://www.example.com:%{SERVER_PORT}/$1 [L,R]

# And for a site running on port 80
RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.example.com/$1 [L,R]

I don't get this, so If I had a domain http://domain.com/index.html and I want http://domain.com How would this work?

Comments

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2013

    Who do you mean by no one?

    check this out because it is a long read but pretty much explains it all

    http://httpd.apache.org/docs/current/mod/mod_rewrite.html

    the concept has to do with telling the server what to do under certain conditions . Think of it as a traffic cop, and an orchestra conductor as well as a Bouncer :)

  • Options
    peregrineperegrine MVP
    edited April 2013

    what version of vanilla?

    I ask because there might possibly be a config setting or something new in vanilla 2.1 that is easy to set up in the same way you can change mail server port.

    What are you asking- your question ins unclear to me. maybe someone else will understand your question.

    Did you say the solutions don't work or are you switching ports or what?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    I don't get this, so If I had a domain http://domain.com/index.html and I want http://domain.com How would this work?

    This sounds like he wants to prettify the url no?

  • Options
    peregrineperegrine MVP
    edited April 2013

    I'm not guessing any more, it's a waste of energy for me to guess, and I'm out of energy :)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    422422 Developer MVP

    my guess is prettify.

    /contact.php = /contact/
    /foo.php = /foo/

    But I have a headache lol

    There was an error rendering this rich post.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    yea I got that part after rereading and omitting the Rewrite rule stuff, that sent me red herring hunting....

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @vrijvlinder said:
    Who do you mean by no one?

    check this out because it is a long read but pretty much explains it all

    http://httpd.apache.org/docs/current/mod/mod_rewrite.html

    the concept has to do with telling the server what to do under certain conditions . Think of it as a traffic cop, and an orchestra conductor as well as a Bouncer :)

    Thank you.

  • Options
    SrggamerSrggamer HardCore Gamer ✭✭✭

    @422 said:
    my guess is prettify.

    /contact.php = /contact/
    /foo.php = /foo/

    But I have a headache lol

    Drink some tea, or eat some fish and chops.

  • Options

    Just to add a related topic - regarding images and .htaccess - if you're interested

    This site generates a bit of code to add to your .htaccess file that can protect your website from hotlinking - http://www.htaccesstools.com/hotlink-protection/

    will ultimately look something like this:

    RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC] RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]

    I had to learn the hard way that a lot of other websites have something like this in place as images embedded within my member's posts started to break.

    From this discussion: http://vanillaforums.org/discussion/comment/179267/#Comment_179267

Sign In or Register to comment.