2 результата для 'htaccess'

  • Опубликовано 2 октября 2014 г.

    If you want to enforce your visitors to access your site over a secure connection only, you can redirect all requests that are not secure to the secure protocol. An easy to way to do this can be accomplished with a .htaccess file containing the following lines.

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
    

    The first line tells Apache we are going to use mod_rewrite. The second line only matches if SSL is not active on this request. If that second line matches then the third line kicks in, which simply redirects the visitor to the SSL version of the requested page.

  • Опубликовано 10 сентября 2014 г.

    To redirect users to the domain page of a website according to the browser default language setting you can use the following .htaccess.

    # French
    RewriteCond %{HTTP:Accept-Language} ^fr [NC]
    RewriteCond %{HTTP_HOST} !^(www\.)?domain\.fr$ [NC]
    RewriteRule ^$ http://www.domain.fr/ [R,L,NC]
    
    # German
    RewriteCond %{HTTP:Accept-Language} ^de [NC]
    RewriteCond %{HTTP_HOST} !^(www\.)?domain\.de$ [NC]
    RewriteRule ^$ http://www.domain.de/ [R,L,NC]
    
    # All other languages
    RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
    RewriteRule ^$ http://www.domain.com/ [R,L]
    

    Of course you can add/change/delete languages and domains according to your own needs.

Страница 1 из 1