![]() |
How to redirect HTTP to HTTPS Using .htaccess |
How to redirect HTTP to HTTPS Using .htaccess And Others Codes
Code Example:
# RewriteCond %{HTTP_HOST} !^www\. [NC] # RewriteCond %{HTTPS}s ^on(s)| # RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^(.*/)?([^/]+)$ /$1index.php?id=$2 [L] # RewriteCond %{THE_REQUEST} ^GET\ /(.*/)?(?:index\.php)?\?id=([^\s&]+) [NC] # RewriteRule ^ /%1%2? [R=301,L] -------------------- # php # RewriteCond %{REQUEST_FILENAME}.php -f # RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L] ---------------- ----------------- # RewriteRule ^Downlode/([0-9]+)/([0-9a-zA-Z_-]+)Downlode.php?id=$1&name=$2 [NC,L] ------------- # RewriteEngine On # RewriteCond %{REQUEST_FILENAME} !-d # RewriteCond %{REQUEST_FILENAME}.php -f # RewriteRule ^index/Downlode/([0-9]+)index.php/Downlode.php?id=$1 [NC,L] --------------- # RewriteCond %{HTTP_HOST} !^www\. [NC] # RewriteCond %{HTTPS}s ^on(s)| # RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^(.*/)?([^/]+)$ /$1index.php?id=$2 [L] # RewriteCond %{THE_REQUEST} ^GET\ /(.*/)?(?:index\.php)?\?id=([^\s&]+) [NC] # RewriteRule ^ /%1%2? [R=301,L] -------------- # php # RewriteCond %{REQUEST_FILENAME}.php -f # RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L] -------- # RewriteRule ^Downlode/([0-9]+)/([0-9a-zA-Z_-]+)Downlode.php?id=$1&name=$2 [NC,L] ------------------ # RewriteEngine On # RewriteCond %{REQUEST_FILENAME} !-d # RewriteCond %{REQUEST_FILENAME}.php -f # RewriteRule ^index/Downlode/([0-9]+)index.php/Downlode.php?id=$1 [NC,L] ----------- RewriteEngine on #if the file does NOT exist (! means NOT, and -f means file exists) RewriteCond %{REQUEST_FILENAME} !-f #if the directory does NOT exit (-d stands for directory exists) RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^Downlode/([A-Za-z0-9-]+)/?$ Downlode.php?id=$1 RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^([^\.]+)$ $1.php [NC] ------------------------- RewriteEngine On RewriteCond %{HTTPS} off # First rewrite to HTTPS: # Don't put www. here. If it is already there it will be included, if not # the subsequent rule will catch it. RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Now, rewrite any request to the wrong domain to use www. # [NC] is a case-insensitive match # RewriteCond %{HTTP_HOST} !^www\. [NC] # RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ---------------
Post a Comment