working on it ...

Filters

Explore Public Snippets

Sort by

Found 5 snippets

    public by chilly_bang  1746  0  6  0

    Redirects non-www to www

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    </IfModule>

    public by chilly_bang  1855  4  6  0

    Force trailing slash, redirect .html to trailing slash, delete more then one slash

    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #Redirects .html to trailing slash
    RewriteRule (.+)\.html$ /$1/ [L,R=301]
    #force trailing slash
    RewriteCond %{REQUEST_URI} !(/$|\.) 
    RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
    # entfernt mehrfache Slashes
    RewriteCond %{REQUEST_URI} ^(.*)\/\/+(.*)$ 
    RewriteRule ^(.*)$ %1/%2 [R=301,L]
    </IfModule>

    public by chilly_bang  2482  1  6  2

    PHP 301 redirect non-HTTPS requests to https://

    Redirects based on port and protocol
    <?php
    if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
    if(!headers_sent()) {
    header("Status: 301 Moved Permanently");
    header(sprintf(
    'Location: https://%s%s',
    $_SERVER['HTTP_HOST'],
    $_SERVER['REQUEST_URI']
    ));
    exit();
    }
    }
    ?>
    
    <?php
    if(!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == ""){
    $redirect = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    header("HTTP/1.1 301 Moved Permanently")
    header("Location: $redirect");
    }
    ?>
    
    <?php
    if ($_SERVER["SERVER_PORT"] != 443) {
    $redir = "Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    header($redir);
    header("HTTP/1.1 301 Moved Permanently");
    exit();
    }
    ?>
    

    public by chilly_bang  1659  1  5  0

    301 Redirect /Homepage.aspx to the root

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^.*/Homepage\.aspx 
    RewriteRule ^(.*)Homepage.aspx$ /$1 [R=301,L]
    </IfModule>

    public by chilly_bang  2230  2  4  1

    Redirect non-HTTPS requests to https://

    2 Redirects: based on protocol and on port
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    </IfModule>
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    </IfModule>

    List Complete ( 5 snippets total )

    • Public Snippets
    • Channels Snippets