Problem Redirecting

I’ve put a rewrite in my .htaccess so that http://example.com and Example Domain will forward to http://www.example.com/. I am also using the default URL action.

My problem is that Example Domain does not forward to http://www.example.com/, it gives me a 401 error message.

(FYI: The server is on Apache 2)

The code I have at the top of the htaccess file is:

RewriteEngine on
rewritecond %{http_host} ^noramclutch.com [nc]
rewriterule ^(.*)$ http://www.noramclutch.com/$1 [r=301,nc]

RewriteCond %{THE_REQUEST} ^./index.html
RewriteRule ^(.
)index.html$ http://www.noramclutch.com/$1 [R=301,L]

The URL to the site: North American Clutch Corporation: NORAM Clutch

Thank you for any suggestions.

Rebecca


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

There are a lot of ways to do this. Out of curiosity try this code
instead. I’ve used it (or a variation of) on many sites without issue.
Perhaps it will work for you. Btw, are you sure mod_rewrite is enabled
on your server?

#Removes file extension
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^/]+)/$ $1.html

# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

Todd

On Aug 3, 2010, at 7:58 PM, rebeccintosh wrote:

I’ve put a rewrite in my .htaccess so that http://example.com and Example Domain
will forward to http://www.example.com/. I am also using the
default URL action.

My problem is that Example Domain does not forward to http://www.example.com/
, it gives me a 401 error message.

(FYI: The server is on Apache 2)

The code I have at the top of the htaccess file is:

RewriteEngine on
rewritecond %{http_host} ^noramclutch.com [nc]
rewriterule ^(.*)$ http://www.noramclutch.com/$1 [r=301,nc]

RewriteCond %{THE_REQUEST} ^./index.html
RewriteRule ^(.
)index.html$ http://www.noramclutch.com/$1 [R=301,L]


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Todd,

No, sorry. That code didn’t work. It would redirect anything.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Try this

RewriteCond %{HTTP_HOST}   !^fully.qualified.domain.name [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://fully.qualified.domain.name/$1 [L,R]

This is from the Apache rewrite guide.

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I replaced the code with the code above, and no luck. Do I need to replace the “domain” with mine and “.name” with .com? I didn’t replace the previous code with anything either.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I found some code that works! Here it is, should anyone else need it.

––––

Options +FollowSymLinks
RewriteEngine On

redirect index.htm and index.html to / (do this before non-www to www)

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.index.html?\ HTTP/
RewriteRule ^(.
)index.html?$ http://www.mydomain.com/$1 [R=301,L]

redirect mydomain.comwww.mydomain.com

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

––––

The code redirects all of the following instances to http://www.mydomain.com/

mydomain.com
mydomain.com/
mydomain.com/index.html
mydomain.com/index.htm
mydomain.com/index.php
www.mydomain.com
www.mydomain.com/
www.mydomain.com/index.htm
www.mydomain.com/index.html
www.mydomain.com/index.php

(Source: http://www.smartlabsoftware.com/howto/redirect-index-page.htm)

Rebecca


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Or you could you this Javascript code embedded into your HTML page.
Ctrl+click in page, select HTML Markup…
Paste the code below.
Change 150*60 to alter the setTimeout for the page to redirect.
~~

~~

Works on all Browsers and platforms for me.
Adrian

On 4 Aug 2010, at 08:09, rebeccintosh wrote:

I found some code that works! Here it is, should anyone else need it.

––––

Options +FollowSymLinks
RewriteEngine On

redirect index.htm and index.html to / (do this before non-www to www)

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.index.html?\ HTTP/
RewriteRule ^(.
)index.html?$ http://www.mydomain.com/$1 [R=301,L]

redirect mydomain.comwww.mydomain.com

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

––––

The code redirects all of the following instances to http://www.mydomain.com/

mydomain.com
mydomain.com/
Web Hosting, Domain Name Registration | MyDomain.com
mydomain.com/index.htm
Page Not Found
www.mydomain.com
www.mydomain.com/
www.mydomain.com/index.htm
www.mydomain.com/index.html
www.mydomain.com/index.php

(Source: http://www.smartlabsoftware.com/howto/redirect-index-page.htm)

Rebecca


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

A JavaScript redirect will work, but it is NOT particularly good in
search engine optimisation (SEO) terms. In fact, it could even have a
negative impact on your site’s SEO.

JavaScript redirects are used to take a page away from someone after
they’ve arrived. This could be used for ‘black hat’ SEO efforts,
trying to set up different pages for search engines and human
visitors and bouncing people to something that’s not what the
(JavaScript-ignoring) search engine spiders see.
Because of this, spiders look for precisley this kind of behaviour
and consider it a possible warning flag.

Server-level redirects, however, are legitimate, instant, and happen
to every visitor regardless of JavaScript capabilities. The
redirection is done before any page content is returned, and the
301 status code is included to tell anything that’s paying attention
that the redirection is permanent. Search engine spiders like this
kind of no-messing, even-handed, standards-respecting redirection.
See Using htaccess for efficient redirection of visitors for some
info on achieving this using a simple .htaccess file.

That’s not to say the JavaScript method shouldn’t ever be used, but
it is important to consider the possible SEO implications. If you do
want to do that way there is a Freeway action that makes it even
simpler than copying and pasting code. Look for Timed Redirect in the
Page actions. (I think this is a standard action - otherwise look
on actionsforge.com)

k


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options