-1

我正在尝试使用此代码重写我的 URL,但它不起作用。你知道我的代码有什么问题吗?我想将 URL 更改为示例:localhost/abc/product.php?id=123变为静态且用户友好的 URL,例如localhost/abc/product/123

我试过这段代码

RewriteEngine on
RewriteRule ^product/([^/.]+)/?$ product.php?id=$1 [L]

但这也是

RewriteRule cat/(.*)/(.*)/$ /script.php?$1=$2
4

2 回答 2

2

原网址:

http://www.localhost/abc/product.php?id=123

改写后的网址:

http://www.localhost/123

利用

RewriteEngine On
RewriteRule ^([^/]*)$ /abc/product.php?id=$1 [L]

模组重写工具

于 2013-10-23T11:24:32.387 回答
1

此规则应在DOCUMENT_ROOT/.htaccess文件中起作用:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(abc)/product/([^/]+)/?$ /$1/product.php?id=$2 [L,QSA,NC]
于 2013-10-23T11:24:23.607 回答