Forum Moderators: phranque

Message Too Old, No Replies

URL rewrite with same URL /pagination

Php mod rewrite

         

chakthiman

8:58 pm on Jun 14, 2014 (gmt 0)

10+ Year Member


Hi... I achieved url rewrite
from [url]http://localhost/DEE/cat.php?cid=55 [/url]to
[url]http://localhost/DEE/55[/url]
Now I want to it for[url]http://localhost/DEE/cat.php?cid=55&pg=2[/url]
How can it from previous rewrite rule�
And my .htaccess file has

RewriteEngine On
RewriteRule /?(\d+)$ cat.php?cid=$1 [L,QSA]
HI I tried my best for title... Sorry if...

lucy24

11:44 pm on Jun 14, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Anything that's present in the target has to be visible in the pattern. You did that in your first rule by pulling "55" (i.e. \d+) out of the path
/DEE/55

and quietly shifting it to
/DEE/cat.php?cid=55


If you want to include pages in the rewrite, you'll have to put them in the URL in some way. Before you start writing rules, figure out exactly what you want these URLs to look like.

[L,QSA]

The QSA flag should not be necessary, because surely the point of this exercise is that the original URL doesn't have a visible query string, right?

Incidentally...
Is this a brand-new site that has never existed before? Pay close attention to your logs. If anyone-- whether human or search engine-- finds out about the "real" URL with query string, you will need to add a set of rules that forcibly redirects them to your desired short-and-pretty form. But if nobody knows the "real" URL exists, you are probably safe.