ddantes
asked on
Redirect only landing page with htaccess
In order to consolidate back link credit, and avoid penalties for duplicate page content, I would like to redirect requests for www.mauitradewinds.com to mauitradewinds.com However, I don't want to redirect requests for other pages in the domain, only the landing page or root page. There are scripts within subdirectories on my site which require the www prefix. Please provide .htaccess code which will permanently redirect only the landing page.
Try this
RewriteCond %{HTTP_HOST} ^(www\.)?mauitradewinds\.com [NC]
RewriteRule ^$ http://mauitradewinds.com [NC,R=301]
ASKER
Thank you both for comments.
GaryC123: Here is the complete .htaccess, including the code which was just added. The root page no longer opens, with or without www...
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Adaptive-Images -------------------------- ---------- ---------- ---------- ---------- ---------- -------
# Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:
RewriteCond %{REQUEST_URI} !js
RewriteCond %{REQUEST_URI} !css
RewriteCond %{REQUEST_URI} !scgi
RewriteCond %{REQUEST_URI} !secure
RewriteCond %{REQUEST_URI} !assets
RewriteCond %{REQUEST_URI} !images/view.jpg
RewriteCond %{REQUEST_URI} !images/StWVT.jpg
RewriteCond %{REQUEST_URI} !images/StWVTsmall.jpg
RewriteCond %{REQUEST_URI} !images/TdwVT.jpg
RewriteCond %{REQUEST_URI} !images/TdwVTsmall.jpg
# don't apply the AI behaviour to images inside AI's cache folder:
RewriteCond %{REQUEST_URI} !ai-cache
# Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
# to adaptive-images.php so we can select appropriately sized versions
RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php
# END Adaptive-Images -------------------------- ---------- ---------- ---------- ---------- ---------- ---
</IfModule>
RewriteEngine On
RewriteBase /
# redirect index.htm to the root domain
RewriteRule ^index\.htm$ / [NC,R,L]
RewriteCond %{HTTP_HOST} ^(www\.)?mauitradewinds\.c om [NC]
RewriteRule ^$ http://mauitradewinds.com [NC,R=301]
GaryC123: Here is the complete .htaccess, including the code which was just added. The root page no longer opens, with or without www...
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Adaptive-Images --------------------------
# Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows:
RewriteCond %{REQUEST_URI} !js
RewriteCond %{REQUEST_URI} !css
RewriteCond %{REQUEST_URI} !scgi
RewriteCond %{REQUEST_URI} !secure
RewriteCond %{REQUEST_URI} !assets
RewriteCond %{REQUEST_URI} !images/view.jpg
RewriteCond %{REQUEST_URI} !images/StWVT.jpg
RewriteCond %{REQUEST_URI} !images/StWVTsmall.jpg
RewriteCond %{REQUEST_URI} !images/TdwVT.jpg
RewriteCond %{REQUEST_URI} !images/TdwVTsmall.jpg
# don't apply the AI behaviour to images inside AI's cache folder:
RewriteCond %{REQUEST_URI} !ai-cache
# Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories
# to adaptive-images.php so we can select appropriately sized versions
RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php
# END Adaptive-Images --------------------------
</IfModule>
RewriteEngine On
RewriteBase /
# redirect index.htm to the root domain
RewriteRule ^index\.htm$ / [NC,R,L]
RewriteCond %{HTTP_HOST} ^(www\.)?mauitradewinds\.c
RewriteRule ^$ http://mauitradewinds.com [NC,R=301]
I'm looking at the site and it seems to be working fine.
Remove the L from
RewriteRule ^index\.htm$ / [NC,R,L]
RewriteRule ^index\.htm$ / [NC,R,L]
ASKER
I get a server access error after making that change. I'm not leaving that .htaccess online, so the site may appear to be working.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did it. Many thanks, Gary.
You could have this code generated automatically, please try here.