Dear Bascht,

Great! It works now.
By the way, the rewrite rule that I used (which does not work) is from this page, under the "URL Layout" section and after the "Canonical Hostnames" heading:

http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

I just don't quite understand what's the problem with the rule, making it failed to work.


----- Original Message ----- From: "Sebastian Schulze" <maili...@bascht.com>
To: <symfony-users@googlegroups.com>
Sent: Friday, January 15, 2010 9:21 PM
Subject: Re: [symfony-users] Why doesn't the mydomain.com -> www.mydomain rewrite rule work in this .htaccess file?


The second line after the RewriteCond is wrong.
It should be more like:

RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*) http://www.mydomain.com$1 [QSA,L,R=301]

Bascht

On 15.01.10 14:16, YTH wrote:
Dear all,

Hi, I would like to allow users getting redirected to www.mydomain.com
if they enter mydomain.com in the browser. I added rewrite rule in the
..htaccess that comes with symfony 1.2 but the rewrite rule does not
seem to work. When users enter mydomain.com, their browser continues to
use mydomain.com, being unaware of the rewrite rule that I added.

The .htaccess file is shown below:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
 RewriteEngine On

 # this is the rewrite rule that I added
 # it should redirect to www.mydomain.com if http_post variable does not
start with www
 # but I have no idea why it does not work
 RewriteCond %{HTTP_HOST}   !^www\.mydomain\.com [NC]
 RewriteCond %{HTTP_HOST}   !^$
 RewriteRule ^/(.*)         http://www.mydomain.com/$1 [L,R=301]

 # uncomment the following line, if you are having trouble
 # getting no_script_name to work
 #RewriteBase /

 # we skip all files with .something
 #RewriteCond %{REQUEST_URI} \..+$
 #RewriteCond %{REQUEST_URI} !\.html$
 #RewriteRule .* - [L]

 # we check if the .html version is here (caching)
 RewriteRule ^$ index.html [QSA]
 RewriteRule ^([^.]+)$ $1.html [QSA]
 RewriteCond %{REQUEST_FILENAME} !-f

 # no, so we redirect to our front web controller
 RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>


I suspected that mod_rewrite is either not installed on the server (it's
a shared hosting server), or it prevents people from doing any override.
After a second thought, I changed my mind because all routing rules such
as /user/new, /product/show defined in routing.yml work perfectly. And
for these routing rules to work, the following rewrite rule defined in
.htaccess must have got executed:

RewriteRule ^(.*)$ index.php [QSA,L]

This means that this might be the problem of my rewrite rule.
Any ideas?

Many thanks to you all.






__________ NOD32 4759 (20100110) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com




--
You received this message because you are subscribed to the Google Groups "symfony users" group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en.





__________ NOD32 4759 (20100110) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

-- 
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-us...@googlegroups.com.
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en.


Reply via email to