Ensuring all links go to index.php
| From: | Dave M G | Date: | Fri, 20 Oct 2006 08:00:05 +0000 |
| Subject: | Ensuring all links go to index.php | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-243377@lists.php.net to get a copy of this message | ||
PHP List,
This problem is a little hard to describe. Please forgive me in advance if it's not clear.
I have set up my .htaccess file to work with my PHP script to create "friendly URLs".
For example, the URL mysite.com/user/login will take the user to a page where a user logs in.
It does this by stripping everything out except "user" and "login". It takes "user" and creates a "user" object, and then passes a "login" method to that class to take the user to the login page.
Somehow, in this process, the local URL is becoming "mysite/user", even though I'm just using that "user" designation to drive the creation of objects from classes.
So, for example, I have a link to logout which is simply href="user/logout".
But when I mouse over it, and look at the status bar at the bottom of my FireFox browser window, it says that the link points to:
mysite.com/user/user/logout
That URL, obviously, doesn't work for my system. It tries to make a "User" object and call a "user" method which doesn't exist.
So... my question is, why is the /user portion of my URL being retained as a directory?
I thought it had something to do with setting headers. I want everything to operate through the index.php file in my root directory, so I thought I could do that by putting this at the top of the index.php page:
header("Location: /");
Or:
header("/local/server/www/directory/");
Bottom line is, how do I ensure that all links and user requests through the URL end up going to the index.php in my web site's root directory?
I hope this question is clear enough, and thank you for any and all advice.
--
Dave M G
Ubuntu 6.06 LTS
Kernel 2.6.17.7
Pentium D Dual Core Processor
PHP 5, MySQL 5, Apache 2