url友好的htaccess PHP

时间:2015-06-09 17:43:40

标签: apache .htaccess

我有一个产品页面,需要用户访问它,但需要使用产品名称。

How it works: localhost/product?id=2

I want it that way: localhost/computer

我的代码.htaccess:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteRule ^confirmation/?$ confirmation.php [NC,L]
   RewriteRule ^/product/([^/]+)/$ product.php?id=$1 [QSA,L]
</IfModule>

不工作,我出错的地方?

1 个答案:

答案 0 :(得分:1)

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteRule ^confirmation/?$ confirmation.php [NC,L]
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^/?([^/]+)/?$ product.php?id=$1 [QSA,NC,L]
</IfModule>