我有category.php,它有?slug='something',所以在用.htaccess:www.example.com/category/football编写了一些代码之后,它看起来是这样的。它运行良好,但我需要实现页面编号,所以我的链接应该是这样的:www.example.com/category/football/page/2。我也是用.htaccess中的一些代码做的,但是它不起作用。
我在category.php中编写了这段代码来表示以下内容:
echo "$_GET['slug']"
if(isset($_GET['page']))
echo $_GET['page']当我去www.example.com/category/football的时候,我收到了来自echo $_GET['slug']的"fudbal“的消息。
但是当我去www.example.com/category/football/page/2的时候,我会从echo $_GET['slug']那里得到echo $_GET['slug']的回音,$_GET['page']也不会给我任何东西。
这是我的.htaccess
Options -Indexes
RewriteEngine on
RewriteRule ^category/([a-zA-Z0-9-/]+)$ themes/tema_2/category.php?slug=$1 [NC,L,QSA]
RewriteRule ^category/([^/]+)/page/(\d+)/?$ themes/tema_2/category.php?slug=$1&page=$2 [NC,L,QSA]在这里试一试:http://htaccess.madewithlove.be/,我有错误:
符合此规则,新的url为2/category.php?slug=fudbal/page/2测试停止,因为RewriteRule选项中的L
发布于 2015-06-01 09:55:04
这应该适用于你:
Options -Indexes
RewriteEngine on
RewriteRule ^category/([^/]+)/?$ themes/tema_2/category.php?slug=$1 [NC,L,QSA]
RewriteRule ^category/([^/]+)/page/(\d+)/?$ themes/tema_2/category.php?slug=$1&page=$2 [NC,L,QSA]https://stackoverflow.com/questions/30570206
复制相似问题