[英]How do I htaccess redirect and rewrite index.php & parameters to new url, without changing links or files?
If I have a website with url of 如果我的网站网址为
/index.php?view=prod&id=11
(where 11 can be any id number) (其中11可以是任何ID号)
How do I redirect and rewrite this to an SEF link like 如何将其重定向和重写为SEF链接,例如
/product/11/
So that anyone that goes to the index.php... link will always get redirected to the SEF link? 这样,转到index.php ...链接的任何人都将始终重定向到SEF链接吗?
My solution so far is 到目前为止,我的解决方案是
RewriteRule ^product/([0-9]+)/?$ index.php?view=prod&id=$1 [NC,L]
But that doesn't redirect the original index.php link at all, and though the SEF link works for some reason it doesn't display any CSS.... which is weird. 但这根本不会重定向原始的index.php链接,尽管SEF链接由于某种原因起作用,但它不显示任何CSS...。这很奇怪。
Thanks. 谢谢。
For the .htaccess
, use: 对于
.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]
Change [R=302]
for [R=301]
when test work well. 测试工作正常时,将
[R=301]
[R=302]
更改为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.