Created
November 8, 2019 05:51
-
-
Save nasirkhan/376ecd163b57c84f68c750d1ab81f6f8 to your computer and use it in GitHub Desktop.
Redirect www to non www domain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Virtual Host Config | |
``` | |
<IfModule mod_ssl.c> | |
<VirtualHost *:443> | |
ServerAdmin webmaster@localhost | |
ServerName matholympiad.org.bd | |
ServerAlias www.matholympiad.org.bd | |
DocumentRoot /var/www/html/matholympiad.org.bd/ | |
<Directory /> | |
AllowOverride All | |
</Directory> | |
<Directory /var/www/html/matholympiad.org.bd/> | |
Options Indexes FollowSymLinks MultiViews | |
AllowOverride all | |
Require all granted | |
</Directory> | |
ErrorLog /var/log/apache2/matholympiad.org.bd-error.log | |
LogLevel error | |
CustomLog /var/log/apache2/matholympiad.org.bd-access.log combined | |
SSLCertificateFile /etc/letsencrypt/live/matholympiad.org.bd/fullchain.pem | |
SSLCertificateKeyFile /etc/letsencrypt/live/matholympiad.org.bd/privkey.pem | |
Include /etc/letsencrypt/options-ssl-apache.conf | |
</VirtualHost> | |
</IfModule> | |
``` | |
## .htaccess config | |
``` | |
#redirect www to website root | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ https://%1/$1 [R=301,L] | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment