Problem in creating rule for url rewriting

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kalpesh
Forum Commoner
Posts: 54
Joined: Sun Sep 21, 2008 5:04 am

Problem in creating rule for url rewriting

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Problem in creating rule for url rewriting

Post 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.
kalpesh
Forum Commoner
Posts: 54
Joined: Sun Sep 21, 2008 5:04 am

Re: Problem in creating rule for url rewriting

Post 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
Post Reply