.htaccess - Trying to enforce http://www in url on a Cake PHP site -
my current .htaccess
file looks this
rewriterule ^$ app/webroot/ [l] rewriterule (.*) app/webroot/$1 [l]
how can add http://www.
in cases?
any appreciated.
the solution independent of php framework it's best resolved in apache configuration (.htaccess):
at top of .htaccess file, after rewriteengine on
directive, include following:
rewritecond %{http_host} ^example\.com rewriterule (.*) http://www.%{http_host}/$1 [r=301,l]
explanation: if site accessed bare domain (example.com
) redirect www
subdomain.
if not using other subdomains (ie. www
) make generic:
rewritecond %{http_host} !^www\. rewriterule (.*) http://www.%{http_host}/$1 [r=301,l]
explanation: if host not start www.
redirect www
subdomain.
Comments
Post a Comment