Yii Framework Forum: Problem With Vhost Conf Rewriting Rule + .htaccess Conf - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problem With Vhost Conf Rewriting Rule + .htaccess Conf Rate Topic: -----

#1 User is offline   SomethingWicked 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 09-January 12

Posted 16 January 2013 - 10:45 AM

Hello all.

The matter: I have plenty of websites to handle, and most of them are yii based. Since I had to fix a bad behaviour on the domain conf (letting the website being surfable from www.domain and domain, risking SEO duplication content error), I decided to redirect every www.domain occurrence in my server, redirecting to the corrispondent domain.com

My approach was to create a vhost.conf, made this way:

code in the next post... :|


This way I can rewrite my www.whatever (secure and not secure).

Once I check it on the server, I can see it is working without problems.

Then I deploy yii and here starts the pain.

This is my htaccess:
#Options +FollowSymLinks
#RewriteEngine on

# 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 [L]


If I have the .htaccess on the root there is no redirect at all, as if no vhost.conf is set.
If I remove the .htaccess the rewrites are ok but I can't hide the front controller, index.php.

I guess that the problem is in the .htaccess, but I'm not a sys admin, so I'm pretty puzzled.

Thanks in advance if anybody can help me to find out what's the problem with this configuration.

ps: I'd prefer to demand the www rewrite a level below than .htaccess, because I actually prepared a vhost.conf skeleton, which should let me create new projects worrying about this matter no more... once it will be fixed, of course :)
0

#2 User is offline   SomethingWicked 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 09-January 12

Posted 16 January 2013 - 10:46 AM

<Directory /var/www/vhosts/domain.com/httpdocs>
	RewriteEngine On
	RewriteCond %{HTTPS} off
	RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
	RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

	RewriteCond %{HTTPS} on
	RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
	RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</Directory>

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users