Apache 如何重定向和重写htaccess index.php&;新url的参数,而不更改链接或文件?

Apache 如何重定向和重写htaccess index.php&;新url的参数,而不更改链接或文件?,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,如果我有一个网址为的网站 /index.php?view=prod&id=11 (其中11可以是任何id号) 如何重定向并将其重写为SEF链接,如 /product/11/ 所以任何进入index.php的人。。。链接将始终重定向到SEF链接 到目前为止,我的解决方案是 RewriteRule ^product/([0-9]+)/?$ index.php?view=prod&id=$1 [NC,L] 但这根本不会重定向原始index.php链接,尽管SEF链接

如果我有一个网址为的网站

/index.php?view=prod&id=11
(其中11可以是任何id号)

如何重定向并将其重写为SEF链接,如

/product/11/
所以任何进入index.php的人。。。链接将始终重定向到SEF链接

到目前为止,我的解决方案是

RewriteRule    ^product/([0-9]+)/?$    index.php?view=prod&id=$1 [NC,L] 
但这根本不会重定向原始index.php链接,尽管SEF链接出于某种原因可以工作,但它不会显示任何CSS。。。。这很奇怪


谢谢。

对于
.htaccess
,请使用:

Options -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} \s/+index\.php\?view=prod&id=([^\s&]+) [NC]
RewriteRule ^ /product/%1/? [R=302,L,NE]

RewriteRule ^product/(\d+)/?$ index.php?view=prod&id=$1 [NC,L]

当测试工作正常时,将
[R=302]
更改为
[R=301]

我目前正在使用XAMPP在本地服务器的子目录中工作。有没有什么原因使这个设置不起作用?我不知道。。。根/基目录的配置错误。您不能使用目录,并且在尝试从根目录重写之后。仍然没有效果,很遗憾。。。即使删除
RewriteBase/
也要更改
RewriteRule^product/%1/?[R=302,L,NE]
没有/到底是什么问题?错误消息?