Php .htaccess具有1个或2个GET参数
我希望在我的Php .htaccess具有1个或2个GET参数,php,.htaccess,Php,.htaccess,我希望在我的中有几个元素。htaccess: 我希望所有的PHP文件都能通过访问/index来工作,而不必将.PHP放在后面 我用过: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteRule ^(.*)/(.*)$ index.php?id=$1&p=$2 RewriteRule ^(.*)$ index.ph
中有几个元素。htaccess
:
- 我希望所有的PHP文件都能通过访问
来工作,而不必将/index
放在后面.PHP
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^(.*)/(.*)$ index.php?id=$1&p=$2
RewriteRule ^(.*)$ index.php?id=$1 [L]
- 我有一个
页面,有时有1个GET参数,有时有2个:index.php
- www.domain.com/?first=数据
- www.domain.com/?first=data&second=data2
- www.domain.com/?first=数据
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^(.*)/(.*)$ index.php?id=$1&p=$2
RewriteRule ^(.*)$ index.php?id=$1 [L]
但只有当我有这两个元素时,它才会起作用;如果我只使用第一个参数的链接,我会得到一个错误页面
我如何解决它?希望它能帮助:
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteRule ^([a-zA-Z-]+)$ index.php?action=$1 [NC,L]
RewriteRule ^(member)-([0-9-]+)$ index.php?action=member&id=$2 [NC,L]
RewriteRule ^([a-zA-Z-]+)/([a-zA-Z-]+)-([0-9-]+)$ index.php?action=$1&saction=$2&sid=$3 [NC,L]
RewriteRule ^([a-zA-Z-]+)/([0-9-]+)$ index.php?action=$1&id=$2 [NC,L]
RewriteRule ^([0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/(.*).html$ index.php?action=details&id=$1&p1=$2&p2=$3&p3=$4 [NC,L]
关于#2,请查看[QSA]
。