302 .htaccess redirects but won't access to other page

Greetings Experts,

Here's the code from the .htaccess:

Redirect 302 /index.php  http://www.mywebsite.com/contact.php

It works in that the contact.php comes up as if it were the index page of the site HOWEVER when I try to access the index.php after loading the site, it won't go there.  It's like the .htaccess is blocking users from accessing the old index.php at all.  I really don't know much about how .htaccess files are written; I see what looks to be some regex in the scripts but I can't be sure.

How must I rewrite the .htaccess so that it will a) redirect users the page I want but once at the website b) allow users to access any page including the index.php (the page which is the subject of the redirect in the .htaccess file).

I hope that was clear and thanks for the help.
Who is Participating?
DangItMarilynConnect With a Mentor Commented:

You can simply make your own DirectoryIndex since we don't have access to the http.conf file.

Put this on the top line in .htaccess

DirectoryIndex contactus.php

That should do it. Be sure to clear your cache before testing!
Well, you redirected the index page so any calls to index.php will be redirected :)
What you'd be better doing might be to rename index.php links to index2.php. For instance you can put a link from contact.php to index2.php, call it "Home" and call it a day.

However, you can also check the order that your server loads pages and put a new page as the redirect.
For instance, if using Apache your index page list might be index.htm, index.php, index.html
In that case, you can make a file called index.htm and leave it blank.
Since it's listed first it'll be the main landing page for any incoming people that just hit the domain.
Then change the redirect to Redirect /index.htm http://www.mywebsite.com/contact.php (the 302 is default and can be omitted) Done :)
max7Author Commented:
>>>Well, you redirected the index page so any calls to index.php will be redirected :)

Point taken ;S

>>>What you'd be better doing might be to rename index.php links to index2.php. For instance you can put a link from contact.php to index2.php, call it "Home" and call it a day.

So basically fix the issue indirectly i.e. the .htaccess file stays in place "as is" just change the page names ... I will consider this if all else fails but I really want to write the .htaccess correctly.

Upon thinking through this again, perhaps what I really want is not so much a redirect but rather, to dub another page as the "default" page.  In other words, index.php is the typical default start page for most any website.  Why not make another page the default?  I assume .htaccess can do this, right?  Perhaps that would not only be easier but make more sense?
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Like option 2, you can see what your server lists first as it's index defaults.
Check this line in httpd.conf

It should look like this:
DirectoryIndex index.html index.php index.cfm index.htm

See how index.html is before index.php? That's going to be the default loaded page for the server when someone doesn't specify .php

So www.mysite.com becomes www.mysite.com/index.html 
but www.mysite.com/index.php still works as expected :)

Just remember to change the redirect to .html instead of .php

Redirect index.html http://www.mysite.com/contactus.php
max7Author Commented:
>>>Check this line in httpd.conf

So since I'm going the "change the default page" route, are you saying I only need to deal with the httpd.conf and won't need the .htaccess anymore?  Also, do all apache servers have the httpd.conf?

>>>Just remember to change the redirect to .html instead of .php

redirect? do you mean default page?  If so, my pages are in .php so wouldn't want to do the opposite of what you wrote?

max7Author Commented:
And actually, I think this discussion might have taken a turn in the wrong, most likely my fault for not explaining clearly.

I'm dealing with a website that's being hosted on paid server so from what I know, I won't have access to the httd.conf, hence the need for the .htaccess ... let me know if I'm missing something in this regard.

If I am right though, I will need to refocus on the writing the .htaccess correctly and with the idea of changing the default page, assuming this is a superior choice over a redirect in that it would allow me to access all pages of the site.
Can you give examples of what URLs you need to transform to what other URLs?
max7Author Commented:
ok ... I've been waiting patiently for my IT director to upload the .htaccess file I created BUT he has been out of town and hasn't done it.  Since I think you've given me some good advice, I would ask that you check out the content of the file I created and tell me if you think it should work or not.  If yes, I will close out this question and award points.

here's the content of the .htaccess file I created, let me know if it should work:

<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
Options Indexes
DirectoryIndex contact.php      
order deny,allow
Written like a pro, Max :)

Now all you need is a new IT guy hehe!

Have a great weekend
max7Author Commented:
Thanks for the help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.