PHP中的Htaccess问题

时间:2010-12-27 13:04:21

标签: .htaccess mod-rewrite

如何重写

www.example.com/test.php?search=demo

  

www.example.com/test/?search=demo

使用htaccess

2 个答案:

答案 0 :(得分:1)

将其放入.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9]+)/?$ $1.php  

答案 1 :(得分:0)

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