Htaccess mod_rewrite:如何将page.php更改为/ page?

时间:2013-08-09 21:07:29

标签: .htaccess mod-rewrite

简单问题:

domain.com应该导致index.php

和domain.com/lala(或任何其他字词)应该导致products.php?name = lala

有人可以给我重写规则吗?

由于

1 个答案:

答案 0 :(得分:0)

假设您的网络根.htaccess目录中有/个文件

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^(.*)$ products.php?name=$1 [R=301,L]

RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^ index.php [R=301,L]