简体   繁体   中英

rewrite url and let more parameters

I am rewriting this kind of urls

http://deia.info/category/calendar/10/

To

/index.php?task=browse_posts&catid=$2

By this code in the .htaccess

RewriteRule ^category/(.+)/(.+) /index.php?task=browse_posts&catid=$2

Which seems to do the job. The problem is when additional parameters are sent, those are ignored.

For example:

http://deia.info/category/calendar/10/?start_date=10

isset($_GET['start_date']) won't return true

Why?

When the incoming URL holds a query like in the OP example:

http://deia.info/category/calendar/10/?start_date=10

The way to combine (Append) it with/to a new query in the substitution URL, is by adding the QSA Flag .

So add [L,QSA] , like this:

RewriteRule ^category/(.+)/(.+) /index.php?task=browse_posts&catid=$2 [L,QSA]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM