www. redirect |
[eluser]mikeyhell[/eluser]
I'm trying to redirect any request to http://domain.com and https://domain.com to http://www.domain.com and https://www.domain.com. Here is the .htacces i'm having to use because it's got cpanel and the normal .htaccess i would use didn't work. Can I do this w/ .htaccess or would it be better/possible to do this in httpd.conf? Code: Options +FollowSymLinks i've also tried the following but get CI error message that my URI submitted has disallowed characters Code: rewritecond %{http_host} ^cartoonsinteaching.com [nc] and also this is my config for the url's Code: $config['base_url'] = "http://".$_SERVER['SERVER_NAME']; when I change "http:// to "http://www. or https://www. I end up with a url like this: http://www.www.domain so I'm confused as to what I need to do.
[eluser]mikeyhell[/eluser]
easy fix w/ a str_replace("www.","",$_SERVER['SERVER_NAME']) in case anyone has the same thing come up.
[eluser]Daniel Moore[/eluser]
You'll want something like this in your .htaccess file to do it from your .htaccess file. The following will ensure that search engines will only look to index your www prefix. Code: RewriteCond %{HTTP_HOST} !^www\.domain\.tld$ [NC] See my CodeIgniter .htaccess tutorial for more details on this.
[eluser]mitchwilson[/eluser]
Thanks. Worked like a charm in .htaccess. I needed this redirect to make sure sessions worked correctly when users left off www when logging in. |
Welcome Guest, Not a member yet? Register Sign In |