working on it ...

Filters

Explore Public Snippets

Sort by

Found 2,725 snippets matching: redirect

    public by afelicioni  7055  1  4  1

    iptables port redirect

    iptables port redirect: iptables
    iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
    
    

    public by JKCPR  2853  4  6  1

    CUSTOM ERROR PAGE || HTTP STATUS REDIRECT

    Very useful for you to point all your error pages to the same file
    <?php
    // Very useful if you point all your error pages to the same file.
    
    // File; .htaccess
    /*# .htaccess file.
    
    ErrorDocument 404 /error-msg.php
    ErrorDocument 500 /error-msg.php
    ErrorDocument 400 /error-msg.php
    ErrorDocument 401 /error-msg.php
    ErrorDocument 403 /error-msg.php
    # End of file.
    
    // File; error-msg.php 
    */#
    ?>
    <?php
      $HttpStatus = $_SERVER["REDIRECT_STATUS"] ;
      if($HttpStatus==200) {print "Document has been processed and sent to you.";}
      if($HttpStatus==400) {print "Bad HTTP request ";}
      if($HttpStatus==401) {print "Unauthorized - Iinvalid password";}
      if($HttpStatus==403) {print "Forbidden";}
      if($HttpStatus==500) {print "Internal Server Error";}
      if($HttpStatus==418) {print "I'm a teapot! - This is a real value, defined in 1998";}
    
    ?>

    public by chilly_bang  2473  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 zonaro  2684  2  6  0

    Redirect WWW

    Redirect all non-WWW Urls to WWW URLs except Localhost URL (allow you to test without unexpected redirects)
    public void RedirectWWW()
            {
                string theURL = Request.Url.ToString();
                if (!theURL.StartsWith("http://www") && !theURL.StartsWith("http://localhost"))
                {
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Status = "301 Moved Permanently";
                    HttpContext.Current.Response.AddHeader("Location", "http://www." + theURL.Replace("http://", ""));
                    HttpContext.Current.Response.End();
                }
    
            }                        

    public by markcl  2763  0  5  0

    Laravel 4 Sentry Redirect Users to Dasboard Snippet

    $jobseekers = Sentry::getGroupProvider()->findByName('Jobseekers');
    $employers = Sentry::getGroupProvider()->findByName('Employers');
    	if($user->inGroup($jobseekers))
    	    return Redirect::to('employerDashboard');
    	// If user is in employers group, go to Jobhunter's Dashboard
    	if($user->inGroup($employers))
    	    return Redirect::to('employerDashboard');

    public by cbbeny  2719  0  5  0

    Redirect website to https

    RewriteEngine On
    RewriteCond %{HTTP:HTTPS} !on [NV]
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    public by chilly_bang  2223  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>

    public by chilly_bang  1791  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 fromano  1869  0  5  1

    Redirect a yarp read to a yarp write while filtering the data

    cut -c 5- will remove all the lines from 1 to 5 tr -d 'characters' will remove all the listed characters By piping the yarp read to the yarp write it is possible to "clean" the input format
    # Enter here the actual content of the snippet.            
    
    yarp read ... /wholeBodyDynamicsTree/floatingbasestate:o | cut -c 5- | tr -d '()' | yarp write /wbd3/clean:o
    
    

    public by chilly_bang  1646  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 Snippets
    • Channels Snippets