HTACCESS

  • 1. SEO Friendly URL
    
                        RewriteEngine On
                        RewriteCond %{REQUEST_FILENAME} !-f
    
                        RewriteRule ^request_link/731463$ /request_link/731463.php [L]
                        RewriteRule ^public_snap/731463$ /public_snap/731463.php [L]
                        RewriteRule ^z0dpk2tw4w$ /z0dpk2tw4w.php [L]
                        
    
                        # php -- BEGIN cPanel-generated handler, do not edit
                        # Set the “ea-php73” package as the default “PHP” programming language.
                        <IfModule mime_module>
                          AddHandler application/x-httpd-ea-php73___lsphp .php .php7 .phtml
                        </IfModule>
                        # php -- END cPanel-generated handler, do not edit
    
    
                        
  • 2. Redirect http to https
    
                    RewriteCond %{HTTPS} off
                    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
                    

    OR

    
                    RewriteCond %{SERVER_PORT} ^80$
                    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
                    
  • 3. Redirect to new url
    
                        RedirectMatch 301 /Roopakalam_thozhal$ https://kanadikavu.com/Roopakalam-thozhal
                        RedirectMatch 301 /public/uploads/pages/$ https://kanadikavu.com/
    
    
                        RedirectMatch 301 /property/details/(.*)$ /wellness-centers/$1
                        RedirectMatch 301 /property/details/(.*)/(.*)$ /wellness-centers/$1/$2
                        RedirectMatch 301 /property/details/(.*)/(.*)/(.*)$ /wellness-centers/$1/$2/$3
    
  • 4. Examples
    
    
                  ErrorDocument 404 /404.html
    RewriteEngine On
    RewriteCond %{SERVER_PORT} ^80$
    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
    
    RewriteCond %{HTTP_HOST} ^bhadraayurveda\.com [NC]
    RewriteRule ^(.*)$ https://www.bhadraayurveda.com/$1 [L,R=301]
    
    
    # Disable directory browsing 
    Options -Indexes
    # Hide the contents of directories
    IndexIgnore *
    
    <ifModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_exclude mime ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    </ifModule>
    
    <IfModule mod_deflate.c>
    ############################################
    ## enable apache served files compression
    ## http://developer.yahoo.com/performance/rules.html#gzip
    
        # Insert filter on all content
        SetOutputFilter DEFLATE
        # Insert filter on selected content types only
        AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
        
        # Netscape 4.x has some problems...
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        
        # Netscape 4.06-4.08 have some more problems
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        
        # MSIE masquerades as Netscape, but it is fine
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        
        # Don't compress images
        SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
        
        # Make sure proxies don't deliver the wrong content
        #Header append Vary User-Agent env=!dont-vary
        
    </IfModule>
    
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType text/html "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType text/x-javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 1 month"
    </IfModule>