ryonn
(Dothebest1)
March 2, 2012, 1:35pm
1
Hi there,
It seems there is a bug with my Yii after setting it online.
Where should I set the htaccess non-www to www ?
RewriteEngine on
#A
#RewriteEngine On
#RewriteBase /
#RewriteCond %{HTTP_HOST} ^mydomain.com
#RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#B
#RewriteEngine On
#RewriteBase /
#RewriteCond %{HTTP_HOST} ^mydomain.com
#RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
# otherwise forward it to index.php
RewriteRule . index.php
#C
#RewriteEngine On
#RewriteBase /
#RewriteCond %{HTTP_HOST} ^mydomain.com
#RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
I think it is B, but it seems none of them works fine… or is it because of the cache?
If it is cache, how can I clear cache in Yii?
Please help
Regards,
Ron
this is what i use:
RewriteEngine on
RewriteBase /
#non-www to www
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
NaX
(Justinfossey)
March 2, 2012, 2:42pm
3
htaccess is an Apache feature and only works if allowed. The default Apache setup support htaccess files out the box. Secondly the mod_rewrite module needs to be enabled.
If you want to redirect from http://domain.com to http://www.domain.com I would also say you need to un-comment section B.
I have used this in the past but with non-Yii websites.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [L,R=301]
</IfModule>
ryonn
(Dothebest1)
March 2, 2012, 9:29pm
4
NaX:
htaccess is an Apache feature and only works if allowed. The default Apache setup support htaccess files out the box. Secondly the mod_rewrite module needs to be enabled.
If you want to redirect from http://domain.com to http://www.domain.com I would also say you need to un-comment section B.
I have used this in the past but with non-Yii websites.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [L,R=301]
</IfModule>
Hi NaX,
I have tried uncomment B, it still gives me errors, so that
mydomain.com/something -> becomes -> www.mydomain.com/something
mydomain.com -> not changing -> mydomain.com
weird isnt it…
Twisted1919, I used your htaccess structure and it works immediately.
Thanks. You’re da man!! =) +1
Yeah, seems that today is my day =)