Forum Moderators: phranque

Message Too Old, No Replies

i got a funny rewrite url

funny rewrite url

         

xbl01234

9:08 pm on Nov 24, 2007 (gmt 0)

10+ Year Member



Hi;
I got a problem with rewrite url, could anyone help me, please.

i am trying to rewrite a url to "http://www.mysite.com/country/page/3/". but the browser give me
the url of "http://www.example.com/country/page/1/country/page/3/" when i click a link
from the page of the "http://www.example.com/country/page/1/", 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 "http://www.mysite.com/country/page/1/".
<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 "http://www.example.com/country/page/1/country/page/3/"
<a href="world/page/8/"> the world </a> <br>
<a href="country/page/3/">the country </a> <br>

[edited by: jdMorgan at 2:14 pm (utc) on Nov. 25, 2007]
[edit reason] examplified per Terms of Service [/edit]

jdMorgan

2:20 pm on Nov 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is an error in your code, but it does not explain the problem you describe. Your second back-reference is incorrect, and should be $2, not $3:

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

It is impossible to comment further without knowing the relationship between the two domains now shown as "mysite" and "example.com" above. For example, are they on the same virtual server, and do you own and/or control both of them?

Also, be sure you are completely flushing your browser cache before testing any changes to your server-side code.

Jim

xbl01234

9:02 am on Nov 26, 2007 (gmt 0)

10+ Year Member



Thanks, i have find out the problem i have.

<a href="world/page/1/"> the world </a> <br>
<a href="country/page/1/">the country </a> <br>

should become as following;

<a href="/world/page/1/"> the world </a> <br>
<a href="/country/page/1/">the country </a> <br>