.htaccess 如何使用htaccess重写规则来更改URL?

.htaccess 如何使用htaccess重写规则来更改URL?,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,如何转换URI,如 "www.mydomain.org/index.php?detail=This is my product name" 到 使用mod_重写和重写规则 有什么办法可以让它工作吗?提前谢谢 将以下内容放入htaccess文件中 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^product/([a-zA-Z0-9]+)/?

如何转换URI,如

"www.mydomain.org/index.php?detail=This is my product name"

使用mod_重写和重写规则


有什么办法可以让它工作吗?提前谢谢

将以下内容放入htaccess文件中

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^product/([a-zA-Z0-9]+)/?$ /index.php?detail=$1 [QSA,L]

当您在
index.php
中获取GET参数时,为什么要在.htaccess中执行此操作?在这里,您可以执行一个简单的
str_replace
。谢谢您的回答,但它不起作用。也许我的解释错了。URL应该是服务器端的www.example.com/index.php?detail=这是我的产品名这可能吗?
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^product/([a-zA-Z0-9]+)/?$ /index.php?detail=$1 [QSA,L]