Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i got a funny rewrite url

Status
Not open for further replies.

xbl12

Programmer
Dec 12, 2006
66
0
0
Hi;
I got a problem with rewrite url, could anyone help me, please.

i am trying to rewrite a url to " but the browser give me
the url of " when i click a link
from the page of the " and it brings me 404 error massage.


The works i have done as following;

.htacess file
RewriteEngine On
RewriteRule ^([a-z]+)/page/([0-9]+)/$ /Category.php?catName=$1&page=$3 [L]


index.php
note: when i click any link from the following, it does the rewrite url well,
for example, give me the rewrite url with the "<a href="world/page/1/"> the world </a> <br>
<a href="country/page/1/">the country </a> <br>

Category.php
note: when i click any link from the following, it give me a funny rewrite url,
for example,a rewrite url with "<a href="world/page/8/"> the world </a> <br>
<a href="country/page/3/">the country </a> <br>
 
The problem is not with your rewite rule but with your links. You are not using the correct relative path in the links. The page where the links are I assume is When you use a link like country/page/3 from that location, apache assumes there is a sub-directory called country off the current directory. Since you mean the country off the root, you need the slash in front which will give the absolute path. If you want to go to /country/page/1 to /country/page/3 then you need to go back to the current directory's parent which is /country/page which also contains /3. The path then should be ../3. I hope that clears things up a bit.
 
Thanks very much, you are right, it does works now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top