Forum Moderators: phranque

Message Too Old, No Replies

301 Redirect

Need help using a Virtual IP.

         

sjbc4119

1:08 am on May 4, 2004 (gmt 0)

10+ Year Member



Hello. I was trying to get for example [house.com...] and [house.com...] to redirect because google is showing 127 links for www and 37 for without www.

I used the following code in my htaccess :

redirect 301/http://house.com [house.com...]

However I can't update my pages onced I entered this command and it didn't redirect. Any suggestions would be greatly appreciated.

HarryM

1:21 am on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe you need to use mod rewrite. I have the following in my htaccess.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) [domain.com...] [R=301,L]

I don't really understand how it works because I got it from one of the threads here. :)

[edited by: jdMorgan at 2:49 am (utc) on May 4, 2004]
[edit reason] Corrected missing required space [/edit]

sjbc4119

1:47 am on May 4, 2004 (gmt 0)

10+ Year Member



Thanks. I tried your sugesstion but not sure if it works. Does your work at least?

HarryM

1:20 pm on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sjbc4119,

I type [domain.www...] in my browser and it redirects to [domain.com...]

jdMorgan,

What space? If it was the space between {HTTTP_HOST} and !^www then it exists in the original although no matter what I try it gets removed by Webmasterworld software. But if it's a different space please let me know.

Why has [NC] dissappeared? Is this unneccessary?

Below is my original with XXX added where the space should be.


RewriteEngine on
RewriteCond %{HTTP_HOST}XXX!^www\.domain\.com [NC]
RewriteRule (.*) [domain.com...] [R=301,L]

jdMorgan

3:23 pm on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



HarryM,

Sorry, yes. Posting on this board removes spaces preceding "!" -- unless you type two spaces ! ;)

And - force of habit... Adding [NC] at the end of the domain name means your ruleset will "accept" upper or lowercase domain names without redirecting them, which sort of defeats the purpose of redirecting non-standard domain name requests. Leave [NC] off unless you have a really good reason to want to allow upper-and mixed-case-domain links to remain in the search engine indexes instead of replacing them with all-lowercase-domain links.


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

Jim

HarryM

8:26 pm on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Jim,

I will remove the [NC]

Harry

sjbc4119

1:22 am on May 5, 2004 (gmt 0)

10+ Year Member



Ok. I think I may know the reason why it doesn't work. Also the actual server is pointing to [example.com....] I used frontpage and here is the htacess:

# -FrontPage-

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) [example.com...] [R=301,L]
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName example.web.hosting_service.net
AuthUserFile /home/u3/example/html/_vti_pvt/service.pwd
AuthGroupFile /home/u3/example/html/_vti_pvt/service.grp

Thanks for your help!

[edited by: jdMorgan at 2:24 am (utc) on May 5, 2004]
[edit reason] No specific URLs, please. See TOS [/edit]

sjbc4119

2:55 am on May 6, 2004 (gmt 0)

10+ Year Member



Yeah the redirect still ddn't work, I left the htacess file. thanks.

jdMorgan

3:08 am on May 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you examine your error logs, you may find a message telling you that FollowSymLinks or SymLinksIfOwnerMatch is disabled. This will disable mod_rewrite.

If so, place the directive


Options +FollowSymLinks

ahead of your RewriteEngine on directive.

This will enable mod_rewrite. Sometimes, you won't have priviledges to use Options. If that is the case, then you may get a 500-Server Error response to all requests. So, try this when your server is not busy, and have a backup .htaccess ready to replace the test version if it doesn't work.

Jim

sjbc4119

11:31 am on May 6, 2004 (gmt 0)

10+ Year Member



I did receive a 500 error, but it still didn't work. I'll call my web server, thanks.