Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Cleaning up just the homepage URL


jdMorgan - 4:22 am on Jun 20, 2007 (gmt 0)


This replaces any/all of your rules pertaining to your home page:

# Externally redirect direct client requests for "index.html" or "index.php" to "/"
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(html¦php)
RewriteRule ^index\.(html¦php)$ http://www.example.com/ [R=301,L]
#
# Internally rewrite requests for "index.html" or "/" to "index.php"
RewriteRule ^(index\.html)?$ /index.php [L]

THE_REQUEST is the entire request header sent by the client. It is never updated as the result of any internal operation, and therefore can be used to differentiate between externally-requested and internally-rewritten URLs, and thereby avoid redirect/rewrite looping.

In order to understand the regex in the RewriteCond, it may help to look at a typical value for THE_REQUEST:
GET /index.php?cc=uk&lang=en HTTP/1.1

The server may internally rewrite requests for "/" to "index.html" as a result of (I assume) a DirectoryIndex directive set in httpd.conf, either by your host or by your use of a "control panel". So, the second rule looks for either "/" or "/index.html" requests (in the top-level directory only), and sends those to your new PHP home page.

Replace all broken pipe "¦" characters in the code above with solid pipes before use; Posting on this forum modifies the pipe characters.

Jim


Thread source:: http://www.webmasterworld.com/apache/3372377.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com