我需要为以下网址创建重写规则,我需要传递" id"和GET超全局的小部件
http://www.domain.com/index.php?id=1866&widget=Dangerfield
是否可以仅使用widget参数&重写的URL中的值仍然和功能一样,如果是这样,怎么样?
答案 0 :(得分:0)
很简单,你可以将它添加到.htaccess
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?id=$1&widget=$2 [L]
原始网址:
http://www.domain.com/index.php?id=1866&widget=Dangerfield
重写的网址:
http://www.domain.com/1866/Dangerfield.html
这是搜索引擎友好的,您的网页将在扩展名为.html的搜索引擎中轻松搜索引擎优化。它比在url末尾的参数更好,这不是seo友好的。
答案 1 :(得分:0)
转向辅助子域
原始网址:
http://domain.com/index.php?cat=cats&id=12&url=stackoverflow
重写的网址:
http://cats.domain.com/12/stackoverflow.html
在.htaccess