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.
LVL 1
max7Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DangItMarilynCommented:
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 :)
0
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?
0
DangItMarilynCommented:
Like option 2, you can see what your server lists first as it's index defaults.
Check this line in httpd.conf
DirectoryIndex

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
0
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

max7Author Commented:
>>>Check this line in httpd.conf
DirectoryIndex

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?


0
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.
0
UmopepisdnCommented:
Can you give examples of what URLs you need to transform to what other URLs?
0
DangItMarilynCommented:
Max,

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!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
</Files>
Options Indexes
DirectoryIndex contact.php      
order deny,allow
0
DangItMarilynCommented:
Written like a pro, Max :)

Now all you need is a new IT guy hehe!

Have a great weekend
0
max7Author Commented:
Thanks for the help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.