Posts

Showing posts with the label htaccess

Redirect website multiple domain to single domain using htaccess

Image
Code: copy below code and create .htaccess file and past it.              RewriteEngine  on                RewriteCond   %{HTTP_HOST}   ^http://domainname.com  [OR]              RewriteCond   %{HTTP_HOST}   ^https://www.domainname.com  [OR]              RewriteCond   %{HTTP_HOST}   ^http://www.domainname.com  [OR]              RewriteCond   %{HTTP_HOST}   ^www.domainname.com              RewriteRule   ^(.*)$   https://domainname.com/$1  [R=permanent,L]             ...

Redirect http to https using htaccess

Image
Code: write below code in .htaccess file.          RewriteEngine  On             RewriteCond   %{HTTPS}   off              RewriteRule   ^(.*)$   https://%{HTTP_HOST}%{REQUEST_URI}  [L,R=301]   

Pretty url using htaccess

Image
Before URL: https://domainname.com/project.php?state=Delhi After URL: https://domainname.com/project/Delhi          RewriteEngine  on          RewriteBase  /          RewriteCond   %{THE_REQUEST}   /project\.php\?state=([^\s&]+)  [NC]           RewriteRule   ^   project/%1?  [R=302,L]           RewriteCond   %{REQUEST_FILENAME}   !-d          RewriteCond   %{REQUEST_FILENAME}   !-f          RewriteCond   %{THE_REQUEST}   /project\?([^\s&]+)  [NC]           RewriteRule   ^   project/%1?  [R=302,L]       ...

Hide php extension from url via htaccess

Image
Before URL:  https://domainname.com/about-us.php After URL:  https://domainname.com/about-us      RewriteEngine  On          RewriteCond   %{REQUEST_FILENAME}   !-d           RewriteCond   %{REQUEST_FILENAME}   !-f           RewriteCond   %{REQUEST_FILENAME}.php   -f           RewriteRule   ^(.*)$   $1.php  [L]     This will not remove the PHP extension automatically from the URL. You need to remove yourself you'll not get any error.