.htaccess RewriteRule 未覆盖 URL

.htaccess RewriteRule not overriding URL

我有这个 .htaccess,它基本上应该将我的链接从

http://www.dsbigiena.ro/products.php?product-id=Colac-wc-cu-folie-de-plastic-cu-actionare-manuala-prin-buton

http://www.dsbigiena.ro/Colac-wc-cu-folie-de-plastic-cu-actionare-manuala-prin-buton/

不幸的是,它没有这样做。

我写错了吗?

RewriteEngine On
RewriteBase /
RewriteRule ^([^/]*)/$ /products.php?product-id= [L]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

编辑:我确实用 "deny from all" 测试了 .htaccess,它确实有效。

您当前的重写规则只能解析一个漂亮的URL。它不会自行将实际的 /products.php URL 转换为漂亮的。你需要有一个明确的规则作为

RewriteEngine On
RewriteBase /

# Redirects from a normal URL to a pretty one
RewriteCond %{THE_REQUEST} \ /products\.php\?product-id=([^\ ]+) [NC]
RewriteRule ^ /%1/? [L,R=301]

# Resolves the pretty URL
RewriteRule ^([^/]+)/?$ /products.php?product-id= [QSA,L]