2011-03-02 43 views
0

我的网址目前看起来像这样如何设置htaccess的产品/项目名称

domain.com/products?product=item 

,并作为产品,我用

RewriteRule ^products$ products.php [L] 

,但我想设置URL中的第一种方式如果我想使用 第一种方法,我是否保留上述重写或删除它?

这是我试过,但它不会工作

RewriteRule ^products/([a-zA-Z])$ products.php?product=$1 [L] 

回答

1

试试这个:

RewriteEngine On 
RewriteCond "%{REQUEST_URI}" "!products\.php" 
RewriteRule "^products/([^/]+).*" "products.php?product=$1" [L,QSA,PT] 

[PT]经常被遗忘。

+0

whats pt用于? – 2011-03-02 23:28:34

+0

'[PT]'表示'通过'并确保Apache的其他部分(如'mod_php')可以查看请求。 – RoUS 2011-03-02 23:29:59

+0

快速的问题,我的样式表打破后,我做了,我只是让他们链接为/css/style.css我需要把他们的域以及? – 2011-03-02 23:37:14

相关问题