简体   繁体   English

Htaccess重写规则,用于在网址中显示标题和类别ID

[英]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 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. 我希望这将调用页面名称default.php或其他什么,我将能够在页面上获得类别ID 22和子类别ID 14。我知道这将是什么.htaccess rewtite规则。

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 它应该产生一个$ _GET数组,如下所示

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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