此重写缺少什么

时间:2019-06-30 19:24:57

标签: php .htaccess mod-rewrite

我有一个只有几页的网站。我也有几个类别和子类别,我已经尝试过.htaccess中的Mod Rewrite Rules,但是它不起作用。用户和卖方的第二个重写规则有效,但是类别重写规则不起作用。

我的设置是Apache服务器,PHP系统,SQL数据库。

这就是我想要做的。

这是PHP中当前的类别链接结构

主要类别 https://www.inoconn.com/category?cat_id=2

儿童类别 https://www.inoconn.com/category?cat_child_id=17

我要完成的工作如下。

主要类别 https://www.inoconn.com/marketing/

儿童类别 https://www.inoconn.com/marketing/seo/

这是我的htaccess代码。

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

RewriteRule ^category/([-\w]+)/(\d+)$ category.php?url=$1&page=$2 [NC,L]

RewriteRule ^([0-9a-zA-Z-_-]+)$ user.php?seller_user_name=$1

我要完成的工作如下。

1 个答案:

答案 0 :(得分:0)

在.htaccess文件顶部检查此规则

RewriteRule ^marketing/$ /category?cat_id=2 [L]
RewriteRule ^marketing/seo/$ /category?cat_child_id=17 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

RewriteRule ^category/([-\w]+)/(\d+)$ category.php?url=$1&page=$2 [NC,L]

RewriteRule ^([0-9a-zA-Z-_-]+)$ user.php?seller_user_name=$1
相关问题