Solved

Redirect index.html to index.php with 301 redirect in .htaccess

Posted on 2007-04-10
2
2,040 Views
Last Modified: 2008-01-09
I have a 301 redirect for my old index page to the new php one like this:

redirect 301 /index.html http://www.mydomain.com/index.php

What I don't like is that when someone goes to http://www.mydomain.com, it appends the index.php to the end of it where it didn't use to before. Does anyone know how to setup the redirect so that when someone goes to http://www.mydomain.com, all they see in the address bar is http://www.mydomain.com instead of http://www.mydomain.com/index.php? Thanks.
0
Comment
Question by:rbichon
2 Comments
 
LVL 4

Accepted Solution

by:
ftsao earned 500 total points
ID: 18884764
Try deleting the index.html file off the server and use the following:

redirect 301 /index.html http://www.mydomain.com

With the redirect rule in your .htaccess file, there shouldn't be a need to keep the old html file.
0
 
LVL 1

Author Comment

by:rbichon
ID: 18884903
I tried that. It causes an infinite loop and the page never loads. It seems like the server thinks that it has to redirect a page back to itself. Here is what I did:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule ^(.*)index.html$ / [L,R=301]

I verified it and it works. Thanks for your help though.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question