2

Can anyone help me with .htaccess rewrite url, I am new to it and stuck with this below problem

i have this urls

http://example.com/catelogue.php?page=3

http://example.com/catelogue.php?page=3&cat1=fruit&cat2=apple

and i want this to be

http://example.com/catelogue

http://example.com/catelogue/fruit/apple

Below is my .htaccess file, but here the problem is I have achieved this (example.com/catelogue/fruit/apple) but I can't redirect my url to (example.com/catelogue).

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^home index.php?page=1 [NC,L]

RewriteRule ^catelogue catelogue.php?page=3 [NC,L]

RewriteRule ^catelogue/([^/.]+)/([^/.]+)$ catelogue.php?page=3&cat1=$1&cat2=$2 [NC,L]
Kumarjit
  • 77
  • 11
  • 1
    possible duplicate of [htaccess rewrite for query string](http://stackoverflow.com/questions/1231067/htaccess-rewrite-for-query-string) – Machavity Jun 23 '15 at 15:45

1 Answers1

2

This should work. Try your rules this way. It works for me.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^catelogue/([^/]+)/([^/]+)$ catelogue.php?page=3&cat1=$1&cat2=$2 [NC,L]
RewriteRule ^catelogue/?$ catelogue.php?page=3 [NC,L]
RewriteRule ^home/?$ index.php?page=1 [NC,L]
Panama Jack
  • 24,158
  • 10
  • 63
  • 95