• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

htaccess 301 redirect of website, excepting certain pages

I'd like to perform a 301 redirect of www.mauitradewinds.com to mauitradewinds.com in order to eliminate the search rank issue of duplicate content.  But there are a few pages in my domain which require the www prefix in order to retain their function.  

In order to have a model for the redirection which I would like to implement, can you suggest .htaccess code which redirects the entire site, except for www.mauitradewinds.com/page1.htm and www.mauitradewinds.com/page2.htm?
0
ddantes
Asked:
ddantes
  • 2
  • 2
1 Solution
 
DamjanCommented:
Try with

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/page1.htm$
RewriteCond %{REQUEST_URI} !^/page2.htm$
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
0
 
ddantesAuthor Commented:
Thank you.  May I ask one more favor?  Could you provide code for redirecting the other way, from non-www to www, except for those two pages?
0
 
DamjanCommented:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/page1.htm$
RewriteCond %{REQUEST_URI} !^/page2.htm$
RewriteCond %{HTTP_HOST} ^mauitradewinds.com
RewriteRule (.*) http://www.mauitradewinds.com/$1 [R=301,L]
0
 
ddantesAuthor Commented:
Thank you very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now