Forum Moderators: phranque

Message Too Old, No Replies

Help me bit to fix it

         

phplearner2006

8:33 pm on Apr 27, 2006 (gmt 0)

10+ Year Member



Hi,
i am new in php .htaccess.

when i call a url from my site like

http://www.example.com/find/computer.php?limit=10&id=4

i am getting the results.

i want to use it more seo friendly so i use a code in my .htaccess file

Options +FollowSymLinks
RewriteEngine on
RewriteRule find/limit/(.*)/id/(.*)/ computer.php?limit=$1&id=$2

but it giving me some different result. The more important thing is i am not able to get my 'id' when i put echo $id; it giving me blank.

i like to use a url like

http://www.example.com/find/limit/10/id/4/

where limit=10 and id=4

please help.

jdMorgan

5:39 pm on Apr 28, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks like your code should work to me. All I can suggest is a more efficient implementation:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^find/limit/([^/]+)/id/([^/]+)/?$ /computer.php?limit=$1&id=$2 [L]

If you are getting any kind of error, check your server error log file.

Jim

phplearner2006

6:21 pm on Apr 28, 2006 (gmt 0)

10+ Year Member



Thanks for your reply.

i have applied the code still i am getting same problem.

one thing if i check the id value from my page after static url request then it will be easy for me to fix the bug

can you please help me to tell the way i can print the id in my page to see.

what i want when call url http://www.example.com/find/limit/10/id/4/

i want print id as 4 in my pages.

hope i can clear up.

again thanks for your reply.

phplearner2006

8:08 pm on Apr 28, 2006 (gmt 0)

10+ Year Member



Here is my full .htaccess code.

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)\.htm$ extra.php?title=$1
RewriteRule category/(.*)/ computer.php?cat_id=$1
RewriteRule ^category/([^/]+)/limit/([^/]+)/?$ /category.php?cat_id=$1&limit=$2 [L]

i want Four issue to be solved.

1)i have 2 other pages as html page when i am calling those html file goes to extra.php what i want to exclude those html file like china.htm.

2) when i call http://example.net/3/ the result is ok.
the page get category as 3 and display result properly.

3) But when i call http://example.com/3/10/ where limit is 10 basically a long page, it expect not getting category and limit properly.displaying error of not getting cat_id and limit.

please help
thanks.

jdMorgan

3:36 am on Apr 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The requested URL http://example.com/3/10/ you tested does not match any of your rules, so it won't be rewritten.
Your rules require that the requested URL either end in ".htm" or start with "category/"

Are your rules incorrect, or did you test a different URL from what you posted?

Note that your rules are not in the right order, since your rule #2 will match anything that might match rules #3. This might be part of the problem. I would re-arrange them like this:


Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{REQUEST_URI} !^/china\.htm$
RewriteRule ^([^.]+)\.htm$ /extra.php?title=$1 [L]
#
RewriteRule ^category/([^/]+)/limit/([^/]+)/?$ /category.php?cat_id=$1&limit=$2 [L]
#
RewriteRule ^category/([^/]+)/?$ /computer.php?cat_id=$1 [L]

Jim

phplearner2006

9:28 am on Apr 29, 2006 (gmt 0)

10+ Year Member



Thanks,

this code is working for me perfectly and giving me to print my cat id and limit perfectly.

Thanks for your help. i really appreciate it.

One more thing i want to tell search engine or redirect url caller to move to my new url.

example,

http://example.net/computer.php?cat_id=3
http://example.net/computer.php?cat_id=2&limit=10

move to

http://example.net/category/3/
http://example.com/category/3/limit/10/

i like to know does the below mentioned code solve my purpose? also can i replace the /category/ portion

like http://example.net/3/ or http://example.com/3/limit/10/

is this code is able to replace my search engine ranking for the page http://example.net/computer.php?cat_id=3 to
new url http://example.net/category/3/ as i use R=301?

so i modified my code like.

Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{REQUEST_URI}!^/china\.htm$
RewriteRule ^([^.]+)\.htm$ /extra.php?title=$1 [L]
#
RewriteRule ^category/([^/]+)/limit/([^/]+)/?$ /computer.php?cat_id=$1&limit=$2 [R=301,L]
#
RewriteRule ^category/([^/]+)/?$ /computer.php?cat_id=$1 [R=301,L]

please help

Thanks for the help

jdMorgan

6:22 pm on Apr 29, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In this forum, we can provide a few minutes of help for specific problems, but we cannot write your code for you. There are simply too many questions, and not enough contributing members to answer them.

This post [webmasterworld.com] should serve to explain how to do what you want, and to get you started coding the solution for yourself.

For aditional information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim