简体   繁体   中英

Htaccess Rewrite Rule for showing title & category id in url

I want to display my title in the url as well as category & subcategory like this.

http://www.phpshiksha.com/php-tutorials-set-time-zone/22-14

I want that this will call a page name default.php or whatever and I will be able to get the category id 22 and subcategory id 14 on the page.May i know what will be the .htaccess rewtite rule for this.

I will appreciate your help.

This should get you started

RewriteEngine on
RewriteRule ^([0-9A-Za-z\-]+)/([0-9]+)-([0-9]+) main.php?title=$1&cat=$2&subcat=$3

It should result in a $_GET array like the following

array(3) {
  ["title"]=>
  string(27) "php-tutorials-set-time-zone"
  ["cat"]=>
  string(2) "22"
  ["subcat"]=>
  string(2) "14"
}

phpshiksha.com/index.php到phpshiksha.com/home的规则

RewriteRule index.php home

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