RewriteCond缺少get参数

时间:2018-01-31 07:05:56

标签: php .htaccess url-rewriting

这是我的.htaccess

RewriteEngine On
RewriteRule ^article/(.*)/(.*)$ article.php?one=$1&two=$2 [L]

当我去article/first/second时这很好用 与article.php?one=fisrt&two=second

相同

但有时只会发送一个参数:article/first

在这种情况下如何制作不同的RewriteRule或RewriteCond  管理这个链接  像article.php?one=fisrt 这是可能的吗?

1 个答案:

答案 0 :(得分:0)

使用此规则

## not index.php
RewriteCond %{REQUEST_FILENAME} !^index.php [NC] 

## if file does not exist then ignore
RewriteRule  ^([\s\S]*)$ index.php?param=$1 [L,NC,QSA]