Can't access my website with www

Everything seems to be working fine when I visit my site with just http://yogacarashop.com , however when I try http://www.yogacarashop.com , I'm led to a Forbidden page.

I'm running Ubuntu 10.04, and currently I've tried redirecting the www to non-www with .htaccess, but that didn't work out. I also tried modifying the apache2.conf in /etc/apache2/apache2.conf to redirect the www to non-www, but that apparently puts it in a redirection loop. I'm not really sure what to do from here.

2 Replies

You have to add ServerAlias inside apache configuration:

    ServerAdmin webmaster@yogacarashop.com
    ServerName yogacarashop.com
    ServerAlias www.yogacarashop.com

EDIT: if it doesn't work, try this .htaccess:

 <ifmodule mod_rewrite.c="">RewriteEngine on

# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]</ifmodule> 

Haha thanks! That did the trick.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct