Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 25, 2012, 11:22:23 AM

Pages: [1]   Go Down
  Print  
Author Topic: I managed to redirect my URL but my blog redirects incorrectly  (Read 1136 times)
grumpytico
Newbie
*
Offline Offline

Posts: 5


« on: September 22, 2008, 03:49:02 PM »

My site is http://www.ingeniumcr.com, and I wanted to redirect anything http://ingeniumcr.com to http://www.ingeniumcr.com. This did the trick:

RewriteEngine on

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

However, my wordpress blog, whose URL is http://www.ingeniumcr.com/resources/wordpress/ redirects to http://ingeniumcr.com/resources/wordpress/ which redirects to http://www.ingeniumcr.com/resources/wordpress/ and loops.

Any idea on what I am doing wrong?

Thanks.
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5219



« Reply #1 on: September 22, 2008, 07:12:19 PM »

I don't get into any loops, but I don't see the "www." being added. What is the purpose of the first RewriteCond? You might try removing it. Don't forget to either clear your browser cache or force a page reload with Ctrl-F5 whenever you change .htaccess.

Another way you might try it:

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


This is your primary domain, and there are no add-on domains or subdomains? Is there any code in this (or any other .htaccess file) put there by Wordpress? Maybe they're doing some redirection on their own.
« Last Edit: September 22, 2008, 07:14:15 PM by MrPhil » Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
grumpytico
Newbie
*
Offline Offline

Posts: 5


« Reply #2 on: September 22, 2008, 09:13:05 PM »

Thanks for your response.   I changed the rules to the ones you posted and redirection worked fine, but the blog keeps redirecting itself  Sad

This is actually an addon domain.  The htaccess file for the primary domain is empty.

I'll leave the .htaccess file changed so you can experience the redirection on the blog.


I don't get into any loops, but I don't see the "www." being added. What is the purpose of the first RewriteCond? You might try removing it. Don't forget to either clear your browser cache or force a page reload with Ctrl-F5 whenever you change .htaccess.

Another way you might try it:

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


This is your primary domain, and there are no add-on domains or subdomains? Is there any code in this (or any other .htaccess file) put there by Wordpress? Maybe they're doing some redirection on their own.
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5219



« Reply #3 on: September 23, 2008, 10:24:35 AM »

OK, so now the "www. add" works, but I get a loop with the blog. The primary domain public_html/.htaccess is empty, and the public_html/ingeniumcr/.htaccess is the one you showed us? Is there anything else in this .htaccess file that you chose not to show us?

Has Wordpress put anything in this .htaccess file, or added its own .htaccess file? Please show the content of public_html/ingeniumcr/resources/.htaccess and public_html/ingeniumcr/resources/wordpress/.htaccess, whichever one(s) exist. Also, in the Wordpress configuration file, is it giving its domain as just ingeniumcr.com, or as www.ingeniumcr.com?
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
grumpytico
Newbie
*
Offline Offline

Posts: 5


« Reply #4 on: September 23, 2008, 08:10:51 PM »

Thanks again for taking the time to look into this.

My public_html/ingeniumcr/.htaccess file has the following:

#INGENIUM

RewriteEngine on

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


My public_html/.htaccess has the following:


RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^saborio/?$ "http\:\/\/www\.ingeniumcr\.com" [R=301,L]


I've erased the contents of this .htacess file and problem persists after a force refresh.

There are no .htaccess file in the places you mention:



Furthermore, my wordpress config file has nothing referring to the domain:



Thanks!


OK, so now the "www. add" works, but I get a loop with the blog. The primary domain public_html/.htaccess is empty, and the public_html/ingeniumcr/.htaccess is the one you showed us? Is there anything else in this .htaccess file that you chose not to show us?

Has Wordpress put anything in this .htaccess file, or added its own .htaccess file? Please show the content of public_html/ingeniumcr/resources/.htaccess and public_html/ingeniumcr/resources/wordpress/.htaccess, whichever one(s) exist. Also, in the Wordpress configuration file, is it giving its domain as just ingeniumcr.com, or as www.ingeniumcr.com?
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5219



« Reply #5 on: September 27, 2008, 12:53:32 PM »

I see everything is working now, except that "www." consistently gets removed. Is that what you finally ended up deciding to do? It shouldn't make any difference to the search engines, so long as everything is either ingeniumcr.com or  www.ingeniumcr.com. I'm guessing that you put something in your .htaccess file(s) to remove www. from your URL, so maybe this is the way you want it. If not, feel free to either post all your .htaccess file(s) here, or PM me with them (if you don't want them shown in public), and I will continue trying to get www. on all your URLs.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
grumpytico
Newbie
*
Offline Offline

Posts: 5


« Reply #6 on: September 30, 2008, 06:55:24 AM »

I  removed the redirect because it made the blog impossible to visit; hence ingeniumcr.com no longer redirects to www.ingeniumcr.com.  If there was a way to keep this redirect working and my blog working as well, I'd be a happy man.

My public_html/.htaccess has the following

RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^saborio/?$ "http\:\/\/www\.ingeniumcr\.com" [R=301,L]


My public_html/ingeniumcr/.htaccess file has the following:

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

I'll leave the redirects turned on so you can see its behavior today (September 30, 2008)

Thanks!


I see everything is working now, except that "www." consistently gets removed. Is that what you finally ended up deciding to do? It shouldn't make any difference to the search engines, so long as everything is either ingeniumcr.com or  www.ingeniumcr.com. I'm guessing that you put something in your .htaccess file(s) to remove www. from your URL, so maybe this is the way you want it. If not, feel free to either post all your .htaccess file(s) here, or PM me with them (if you don't want them shown in public), and I will continue trying to get www. on all your URLs.
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5219



« Reply #7 on: September 30, 2008, 07:57:35 AM »

OK, I see ingeniumcr.com being redirected to www.ingeniumcr.com, but something causes a loop when trying to bring up the blog. Is that what you see?

Just to check, you have some primary domain, and ingeniumcr.com is an add-on domain, with a root directory of public_html/ingeniumcr/. Correct?

Your public_html/.htaccess has problems.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^saborio/?$ "http\:\/\/www\.ingeniumcr\.com" [R=301,L]


The RewriteCond matches any  host, so it's not really doing anything and can be omitted. Is this "saborio" directory under public_html/, and not public_html/ingeniumcr/? Is this redirection a separate issue from adding www. to ingeniumcr.com and the blog problem? The RewriteRule pattern (^saborio/?$) will match only  ...primarydomain.com/saborio or ...primarydomain.com/saborio/. Are you deliberately trying to match only those two cases, and not any pages under that directory (e.g., ...primarydomain.com/saborio/index.php will not be matched). If you change the pattern to ^saborio/?(.*)$ you will match anything beyond just that directory, and can transfer it to the target with $1 (if that's what you're trying to do). Finally, it is unnecessary to escape characters in the target. This is just text to be substituted, not a pattern to match, so you want http://www.ingeniumcr.com  (without the " quotes, too). If you omitted the RewriteCond, you can get rid of the L flag too.

If you want just ...primarydomain.com/saborio and ...primarydomain.com/saborio/ to be redirected to www.ingeniumcr.com, you would do:

RewriteEngine On
RewriteRule  ^saborio/?$   http://www.ingeniumcr.com  [R=301]


If you want to preserve the path and file information,

RewriteEngine On
RewriteRule  ^saborio/?(.*)$  http://www.ingeniumcr.com/$1  [R=301]


should work. Or at least, it would work if ingeniumcr.com was your primary domain. Depending on the exact server configuration, it may have trouble redirecting to an add-on domain. In that case, you could try

RewriteEngine On
RewriteRule  ^saborio/?(.*)$  /ingeniumcr/$1  [R=301]


and let the other .htaccess file take care of the domain name.

Your public_html/ingeniumcr/.htaccess file looks like it should work:

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


It should match a host name of exactly ingeniumcr.com and redirect it to the www form. That seems to work.

The question is why does your blog go into a loop? ingeniumcr.com --> www.ingeniumcr.com and back in an endless loop. Is there a further .htaccess file deeper down? Maybe in public_html/ingeniumcr/resources/wordpress/.htaccess? Have you confirmed that there are no other .htaccess files (installed by Wordpress)? That's all I can think of... that maybe there's another .htaccess file that's redirecting you back from www.ingeniumcr.com to ingeniumcr.com.

If there are no additional .htaccess files, you might try the following. Erase or hide public_html/ingeniumcr/.htaccess. In public_html/.htaccess:

RewriteEngine On
# assume standard Lunarpages setup of add-on domain coming in as primarydomain.com/addon_dir/

# redirect references to saborio to ingeniumcr.com
RewriteRule  ^saborio/?(.*)$   /ingeniumcr/$1   [NC]

# give ingeniumcr.com its proper name
# assuming at this point it's  primarydomain.com/ingeniumcr/...
RewriteRule  ^ingeniumcr   http://www.ingeniumcr.com/$1  [NC,R=301]


Let us know how it turns out, and which method you had to use. Don't forget to clear your browser cache after any change to .htaccess.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
grumpytico
Newbie
*
Offline Offline

Posts: 5


« Reply #8 on: September 30, 2008, 08:22:40 AM »

Yup, the behavior you are seeing is the one I have and yes, ingeniumcr.com is an add-on domain, with a root directory of public_html/ingeniumcr/.

OK, I see ingeniumcr.com being redirected to www.ingeniumcr.com, but something causes a loop when trying to bring up the blog. Is that what you see?

Just to check, you have some primary domain, and ingeniumcr.com is an add-on domain, with a root directory of public_html/ingeniumcr/. Correct?
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: