Forum Moderators: phranque
Right away, I found out that it is better to do a permanent redirect from http://example.com/ to http://www.example.com/
That I have done.
But now, after checking google page rank, I noticed that my page http://www.example.com/ is ranked higher than http://www.example.com/index.cgi .... but they are the same. In apache, I have root files [index.html, index.php, index.cgi, etc].
Is there a way for apache to permanent redirect my users accessing the root "/" to change the url to "/index.html" if it exist, "/index.php" if it exist, etc?
CCF
[edited by: jdMorgan at 3:07 pm (utc) on Sep. 6, 2007]
[edit reason] example.com. [/edit]
Also, there is no reason to reveal what kind of file you use, either to the user or to search engine robots. Consider this: What if you change your main index page from /index.cgi to /index.php? If that page is indexed in search engines as /index.cgi and you change it to /index.php, then that is a new URL; You will lose your search ranking on that page for anywhere from three weeks to a year, depending on your page's ranking and how often it is indexed.
Furthermore, what about type-in traffic? Why require the user to type in the extra URL-path to get your index page?
Therefore, it's best to always link just to "/" and use the DirectoryIndex directive to tell Apache how to map that URL-path to the correct server filepath without revealing that filepath to clients.
Jim
How about that if someone access "index.cgi", it redirects them to "/"? I tried to do this, and it almost worked. However when I tried, I was stuck in an infinite loop.
In my htaccess file I had:
RewriteCond %{REQUEST_URI} ^.*index.cgi$
RewriteRule (.*)index.cgi [domainname.com...] [R=301,L]
I think its because I have "index.cgi" in my DirectoryIndex
DirectoryIndex index.html index.wml index.cgi
Why am I bothering? Simply because search engines consider [domainname.com...] and [domainname.com...] two different page.
CCF
RewriteCond %{THE_REQUEST} ^.*\/index\.html?
RewriteRule ^(.*)index\.html?$ [domain.com...] [R=301,L]
OR
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ [domain.com...] [R=301,L]
Can anyone explain the difference between the two?
CCF