Welcome to WebmasterWorld Guest from 54.226.143.14

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirect in same site

All urls going to index page

   
9:55 am on May 14, 2004 (gmt 0)

10+ Year Member



Hi

I wonder if you could help.

I am trying to set up an htaccess instruction that will basically send all urls for a site to the index.html page of the same site.

For example, if I enter [site.com...] it will just go to [site.com...]

and the same for any possible url whether it it actually exists on the sever or not.

The reason for this is that I have an old site that basically nw just consists of the index.html page all the other stuff has been cleared out - but there are many links etc to specific pages on the site that I would like just directed to the index page. I've tried a few things but non seem to work.

10:08 am on May 14, 2004 (gmt 0)

10+ Year Member



Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}!index\.html
RewriteRule (.*) [site.com...] [R=301,L]

Should work.

10:12 am on May 14, 2004 (gmt 0)

10+ Year Member



I put the following into htaccess:

Order Deny,Allow
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}!index\.html
RewriteRule (.*) [mysite.com...] [R=301,L]

I get internal server error for any url to that site

2:36 pm on May 14, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



jdingley,

Welcome to WebmasterWorld [webmasterworld.com]!

You'll need to add a required space preceding the "!" in the RewriteCond. Posting on this board invokes a filter that removes "extra" spaces, and our code falls victim to it. The work-around is to type two spaces.

Also, you won't need the "Order" directive, unless you have subsquent "Allow from" and/or "Deny from" directives.

I've occasionally used something like this:


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index\.html$
RewriteRule (.*)\.html$ http://www.mysite.com/index.html [R=301,L]

Note that only requests for html pages are redirected to index.html. Otherwise all requests, including those for images and scripts, would be redirected to index.html.

Jim

[edited by: jdMorgan at 2:44 pm (utc) on May 14, 2004]

2:43 pm on May 14, 2004 (gmt 0)

10+ Year Member



That did it.

I put the above code in by cutting and pasting.

Thanks very much!

2:45 pm on May 14, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



We cross-posted - See my edit above.

Also, see this thread [webmasterworld.com] for a related issue.

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month