homepage Welcome to WebmasterWorld Guest from 54.166.100.8
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirect in same site
All urls going to index page
jdingley




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

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.

 

Paul in South Africa




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

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

Should work.

jdingley




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

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

jdMorgan




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

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]

jdingley




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

That did it.

I put the above code in by cutting and pasting.

Thanks very much!

jdMorgan




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

We cross-posted - See my edit above.

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

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved