Redirection with on (apache2, ubuntu 10.04)?

All kind time of day!

Faced with this problem, you must redirect to the website with on

Google gave two main Council: it is with mod_rewrite conditions to redirect type
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Or direct redirect using virtual hosts type
<VirtualHost *>
 Redirect 301 /

The second method doesn't work for me (Firefox gives an error about infinite redirects), the first works, but here's the thing: if writing to the primary address additional parameters, e.g. no redirect occurs.

Please tell me how to fix it?

P. S. the sites are not engaged, to understand the syntax of this mod no desire... Only in the most extreme case.

Thank you!
October 8th 19 at 02:29
7 answers
October 8th 19 at 02:31
Difference in single $ character in the first line
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
October 8th 19 at 02:33
in .htaccess

RewriteCond %{HTTP_HOST} ^www.domain\.com$ [NC]<br> RewriteRule ^(.*)$ <a href=""></a>$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]<br> RewriteRule ^(.*)$ <a href=""></a>$1 [R=301,L]

if suddenly does not plow add on the selected option
Options +FollowSymLinks<br> RewriteEngine On
October 8th 19 at 02:35
If Apache in front of nginx to redirect them organize better
October 8th 19 at 02:37
RewriteEngine on
RewriteCond %{HTTP_HOST} !^se\.solovyev\.org$
RewriteRule ^{REQUEST_URI} [R=301,L]

Code on github
Sorry, the parser ate:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^se\.solovyev\.org$
RewriteRule ^ <a href="{REQUEST_URI}">{REQUEST_URI}</a> [R=301,L] 
- Cordell75 commented on October 8th 19 at 02:40
October 8th 19 at 02:39

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ %1%{REQUEST_URI} [R=301,L]

here is a literate version of boilerplate. Virtually the same as comment n. 1
October 8th 19 at 02:41
Thank you all! It seems to work
October 8th 19 at 02:43
One option which I always use:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]

Find more questions by tags Apache