Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/245.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess具有1个或2个GET参数_Php_.htaccess - Fatal编程技术网

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]
  • 我有一个
    index.php
    页面,有时有1个GET参数,有时有2个:

    • www.domain.com/?first=数据
    • www.domain.com/?first=data&second=data2
我用过:

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]