Need mod_rewrite condition and rule to replace “.com” with “.org” on 1 virtual host?

I asume your site is reachable by two domains, but you want all request to your site redirected to one of them. Then the correct code is: RewriteCond %{HTTP_HOST}! ^mydomain\.

Com$ NC RewriteCond %{HTTP_HOST}! ^$ RewriteRule ^(.*)$ mydomain.org/$1 R=permanent,L You should place that code directly after the redirect line The second line makes sure that there is no redirect if no Host is given (to prevent a redirect loop in that case) The R=permanent,L in the third line makes it a permanent redirect and prevents any further rule processing. The other rules will be processed once the redirect has taken place The full file would then be: Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST}!

^mydomain\. Com$ NC RewriteCond %{HTTP_HOST}! ^$ RewriteRule ^(.*)$ mydomain.org/$1 R=permanent,L RewriteCond %{REQUEST_FILENAME}!

-f RewriteRule ^(.*)$ /app/core. Php L,NC,QSA.

I asume your site is reachable by two domains, but you want all request to your site redirected to one of them. Then the correct code is: RewriteCond %{HTTP_HOST}! ^mydomain\.

Com$ NC RewriteCond %{HTTP_HOST}! ^$ RewriteRule ^(.*)$ mydomain.org/$1 R=permanent,L You should place that code directly after the redirect line. The second line makes sure that there is no redirect if no Host is given (to prevent a redirect loop in that case).

The R=permanent,L in the third line makes it a permanent redirect and prevents any further rule processing. The other rules will be processed once the redirect has taken place. The full file would then be: Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST}!

^mydomain\. Com$ NC RewriteCond %{HTTP_HOST}! ^$ RewriteRule ^(.*)$ mydomain.org/$1 R=permanent,L RewriteCond %{REQUEST_FILENAME}!

-f RewriteRule ^(.*)$ /app/core. Php L,NC,QSA.

Thanks @Chronial. Your assumption is correct according to the way you stated it. So does the entire snipit of directives look like this: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST}!

^mydomain\. Com$ NC RewriteCond %{HTTP_HOST}! ^$ RewriteRule ^(.*)$ http://mydomain.org/$1 R=permanent,LRewriteBase / RewriteCond %{REQUEST_FILENAME}!

-f RewriteRule ^(.*)$ /app/core. Php L,NC,QSA – Dr. DOT Aug 10 at 18:31 @Chronial...I can't seem to format my comment to reveal readable code so look at the next answer for my revised directives and tell me if that is the solution I should use. – Dr. DOT Aug 10 at 18:38 As I said you have to place my code after the RewriteBase command.

Updated my answer to include the full code. – Chronial Aug 10 at 23:40 Ok thanks @Chronial. When I read what you said above "You should place that code directly after the redirect line" I wasn't sure that "redirect line" actually meant rewrite base.

I am learning :) – Dr. DOT Aug 11 at 1:25 Well, it did not work. Other, unrelated virtual hosts on the server showed as a repetitive series of redirect messages in the browser status bar and never resolved the page. Mydomain.Com actually showed the temp landing page which it was not supposed to do -- it was supposed to show the .

Org site. And mydomain.Org just sat at a white screen with the progress bar slowing moving and I killed the whole thing after is sat there for about 30 clock seconds. So I think I will just move on.

Thanks for taking a shot at it. – Dr. DOT Aug 11 at 1:36.

Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST}! ^mydomain\. Com$ NC RewriteCond %{HTTP_HOST}!

^$ RewriteRule ^(.*)$ mydomain.org/$1 R=permanent,L RewriteBase / RewriteCond %{REQUEST_FILENAME}! -f RewriteRule ^(.*)$ /app/core. Php L,NC,QSA.

That did not work. – Dr. DOT Aug 10 at 20:55.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions