Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
htaccess no www AND 301 redirect
Old 01-22-2010, 03:24 PM Question htaccess no www AND 301 redirect
Novice Talker

Posts: 5
Name: Henk
Trades: 0
I need help with the .htaccess

I have several sites which I redirect 301 with:

Code:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mysite\.nl
RewriteRule ^(.*) http://www.mysite.nl/$1 [L,R=301]
So all my previous domains go there. www.aaa.nl www.bbb.nl all redirect to www.mysite.nl
So far so good.

But now I want to change also www.mysite.nl into mysite.nl

How do I code this?
cuban8 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-22-2010, 04:07 PM Re: htaccess no www AND 301 redirect
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,390
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
take out the www. from the RewriteRule and remove the"!" from the RewriteCond
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-22-2010, 04:17 PM Re: htaccess no www AND 301 redirect
Novice Talker

Posts: 5
Name: Henk
Trades: 0
Does indeed change www into no www.

But I have now www.aaa.nl changed into www.mysite.nl

When I do your suggested change, you keep browsing in www.aaa.nl (in the browserwindow). This does not change into mysite.nl as I have before your suggestion...
cuban8 is offline
Reply With Quote
View Public Profile
 
Old 01-22-2010, 04:21 PM Re: htaccess no www AND 301 redirect
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,390
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
and the rules for the other hostnames are??
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-23-2010, 06:12 AM Re: htaccess no www AND 301 redirect
Novice Talker

Posts: 5
Name: Henk
Trades: 0
I finally got it.

The domain pointer was as an 'alias''. I removed this and now it is working.

Just a final question, as I am eager to learn... What does the ! do in the rule?
cuban8 is offline
Reply With Quote
View Public Profile
 
Old 01-23-2010, 06:29 AM Re: htaccess no www AND 301 redirect
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,390
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
A "!" is the NOT (negation) operator in regular expressions (and many other languages).

So !^www means "Not starting with www "
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-23-2010, 07:12 AM Re: htaccess no www AND 301 redirect
Novice Talker

Posts: 5
Name: Henk
Trades: 0
OK! I also do not have a $ behind: Rewriterule ^(.*)
In several cases I see the $ as well. What does that mean?
cuban8 is offline
Reply With Quote
View Public Profile
 
Old 01-23-2010, 07:29 AM Re: htaccess no www AND 301 redirect
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,390
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
$ defines the ending of a 'line' (ending anchor), and when followed by a number from 1 to 9, also references a variable defined in the RewriteRule pattern (used for variables on the right side of the equation or to match a variable from the rule in a condition,
http://www.webmasterworld.com/forum92/4332.htm
and
http://www.yourhtmlsource.com/sitema...rewriting.html
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-23-2010, 07:49 AM Re: htaccess no www AND 301 redirect
Novice Talker

Posts: 5
Name: Henk
Trades: 0
Ok, but how does that influence my rule in my .htaccess?
cuban8 is offline
Reply With Quote
View Public Profile
 
Old 01-23-2010, 07:53 AM Re: htaccess no www AND 301 redirect
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,390
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
it means that everything after the www.xxx.nl/ will be appended onto the new url

so www.site.nl/a/b/c/d/ will become site.nl/a/b/c/d/
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to htaccess no www AND 301 redirect
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29750 seconds with 12 queries