重写网址www.domain.com/model.php?mode=add到www.domain.com/model/add

时间:2022-05-16 11:20:29

i want to change www.domain.com/model.php?mode=add to www.domain.com/model/add and not just for model.php but for others as well

我想将www.domain.com/model.php?mode=add更改为www.domain.com/model/add,而不仅仅是针对model.php而是针对其他人

previously I've tried like this

以前我试过这样的

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^(.*)/(.*)/ $1.php?mode=$2 [L]

1 个解决方案

#1


I would be more specific:

我会更具体:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z]+)/?$ $1.php [NC]
RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/?$ $1.php?mode=$2 [NC]

with NC|nocase to be matched in a case-insensitive manner.

使用NC | nocase以不区分大小写的方式进行匹配。

#1


I would be more specific:

我会更具体:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z]+)/?$ $1.php [NC]
RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/?$ $1.php?mode=$2 [NC]

with NC|nocase to be matched in a case-insensitive manner.

使用NC | nocase以不区分大小写的方式进行匹配。