I must redirect world wide web.example.com to example.com.

The next htaccess code makes this happen:

 RewriteCond % ^www.example.com [NC]

 RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

But, it is possible to method of doing this inside a generic fashion without indicating the domain title?

RewriteCond % ^www.(.*)$ [NC]

RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Just like Michael's except that one works :P

But when we have to do that for separate http and https:

  RewriteCond % off

  RewriteCond % ^www.(.*)$ [NC]

  RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

  RewriteCond % on

  RewriteCond % ^www.(.*)$ [NC]

  RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Redirect non-world wide web to world wide web (both: http + https)

RewriteCond % off

RewriteCond % !^www.(.*)$ [NC]

RewriteRule ^(.*)$ http://world wide web.%/$1 [R=301,L]

RewriteCond % on

RewriteCond % !^www.(.*)$ [NC]

RewriteRule ^(.*)$ https://world wide web.%/$1 [R=301,L]

If you wish to do that within the httpd.conf file, it can be done without having mod_rewrite (and apparently it's better for performance).

<VirtualHost *>

  ServerName world wide web.example.com

  Redirect 301 / http://example.com/


I acquired that answer here: http://serverfault.com/questions/120488/redirect-url-within-apache-virtualhost/120507#120507

Please visit here:

http://no-world wide web.org/

They have got code samples for apache.

Do this:

RewriteCond % ^www. [NC]

RewriteRule ^(.*)$ %$1 [C]

RewriteRule ^www.(.*)$ http://$1 [L,R=301]

When the host begins with world wide web, we stick the entire host onto the beginning of the URL, then remove the "world wide web."

RewriteCond % ^www.(.*)$ [NC]

RewriteRule ^/(.*)$ http://%1/$1 [R]

The RewriteCond captures my way through the HTTP_HOST variable after the "world wide web." and saves it in %1. The RewriteRule captures the URL (sans leading "/") and saves it in $1.

There might be lots of untrue stories available about htaccess redirects, I've found. To begin with, make certain your internet site is running on Unix using Apache and this is not on a Home windows host should you expect this code to operate.

RewriteEngine On

RewriteCond % ^www.(.+)$ [NC]

RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

(Make certain you will find no line spaces in between each type of text, though I've added an additional space between lines therefore it renders okay within this window.)

This really is one snippet of code you can use to direct the world wide web version of the site towards the http:// version. You will find other similar codes you can use, too.

20 good examples of .htaccess

the only method Time passes, I battled for half an hour to provide mind. Just idea

RewriteEngine On RewriteCond % ^site.ro RewriteRule (.*) http://world wide web.site.ro/$1 [R=301,L]

RewriteCond % ^www.(.*)$ [NC]

RewriteRule ^(.*)$ http://%1/subfolder/$1 [R=301,L]

For subfolder