Page 1 of 1

Problem in creating rule for url rewriting

Posted: Sun Jan 11, 2009 7:55 am
by kalpesh
Hi i am new to php.
I want to url rewrite for my site.
I having problem for creating rule for url rewriting.

I have one page whose link is like this:
http://www.example.com/Category/Category.php?Cat_Id=1
I want to have like this:
http://www.example.com/1/Category.html

Other Page like this:
http://www.example.com/Product/Product.php?Name=Example
I want to have like this:
http://www.example.com/Example/Product.html

Please Help Me
Thanks in Advance.

Re: Problem in creating rule for url rewriting

Posted: Sun Jan 11, 2009 8:55 am
by requinix
You should have asked in the Regex forum.

Code: Select all

RewriteRule ^/?(\d+)/([^.])(.html)?$ /???/???.php?Cat_Id=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([^/]+)/([^.]+)(.html)?$ /???/???.php?Name=$1 [L,QSA]
I didn't know where $2 should belong since the directory and file both had the same values. Replace the ???s appropriately.
If you have real directories that are just numbers then you'll need those two RewriteConds for the first rule too.

Re: Problem in creating rule for url rewriting

Posted: Mon Jan 12, 2009 1:25 am
by kalpesh
Thank you tasaris.
I really appreciate your help.
We have discuss this issue also before.
but that time i didn't figure out this problem.
But this time I got problem solved.
Thanks for your help and be patience with me.
:lol: :P