Is anyone familiar with a modular design site and how to create links using mod_rewrite. I discovered for mod_rewrite to
work, my links must be how they would look in the address bar like this: href=”login” instead of: href=”index.php?p=login”.
I got that to work, but I have problems when I take it a step further and pass additional information through the address
bar url as described below.
RewriteRule ^([a-z]+)/?([a-z]+)?/?$ index.php?p=$1&action=$2
index.php sandwiches together the files to display like (header.html, register.php, footer.html).
All urls are modified by .htaccess and sent to index.php. Index.php $_GET's p=$1 and action=$2.
The header.html has links. The links are accessible on all the pages because they're in the header.
If I click on register, I go to register.php. Looks good, nothing wrong here.
After I fill out form on register I get redirected to login: header('Location: login/jr'); exit;
This means index.php?p=$1&action=$2 where p=login and action=jr (just registered).
Index.php $_GET's p and action and places those values in $p and $action and properly directs me to login.php
Now the address bar url says this: http://www.mysite.com/login/jr
Here is where I run into a problem; NOW I click on href=”home” in the header, I am sent here:
http://www.mysite.com/login/home instead of:
The link href=”home” attaches "home" after http://www.mysite.com/login/
Is there a standard solution to this kind of problem? Am I doing this wrong? Thanks.
Put a forward slash in front of your URLs
Thank you for responding.
That was was the answer. It works perfectly now. I have been wrestling with this sense yesterday.
This topic is now closed. New replies are no longer allowed.