How to Set AllowOverride all

In case you are on Ubuntu, edit the file /etc/apache2/apache2.conf (here we have an example of /var/www): <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> and change it to; <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> then, sudo service apache2 restart You may need to also do sudo … Read more

Redirect non-www to www in .htaccess

Change your configuration to this (add a slash): RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule (.*) http://www.example.com/$1 [R=301,L] Or the solution outlined below (proposed by @absiddiqueLive) will work for any domain: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] If you need to support http and https and preserve the protocol choice try the following: … Read more

How to automatically redirect HTTP to HTTPS on Apache servers?

I have actually followed this example and it worked for me 🙂 NameVirtualHost *:80 <VirtualHost *:80> ServerName mysite.example.com Redirect permanent / https://mysite.example.com/ </VirtualHost> <VirtualHost _default_:443> ServerName mysite.example.com DocumentRoot /usr/local/apache2/htdocs SSLEngine On # etc… </VirtualHost> Then do: /etc/init.d/httpd restart

How does RewriteBase work in .htaccess

RewriteBase is only applied to the target of a relative rewrite rule. Using RewriteBase like this… RewriteBase /folder/ RewriteRule a\.html b.html is essentially the same as… RewriteRule a\.html /folder/b.html But when the .htaccess file is inside /folder/ then this also points to the same target: RewriteRule a\.html b.html Although the docs imply always using a … Read more

Force SSL/https using .htaccess and mod_rewrite

For Apache, you can use mod_ssl to force SSL with the SSLRequireSSL Directive: This directive forbids access unless HTTP over SSL (i.e. HTTPS) is enabled for the current connection. This is very handy inside the SSL-enabled virtual host or directories for defending against configuration errors that expose stuff that should be protected. When this directive … Read more

.htaccess redirect all pages to new domain

The below answer could potentially cause an infinite redirect loop… Here, this one redirects everything after the domain name on the URL to the exact same copy on the new domain URL: RewriteEngine on RewriteRule ^(.*)$ http://www.newdomain.com/ [R=301,L] www.example.net/somepage.html?var=foo redirects to: www.newdomain.com

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)