URL重写规则.htaccess

URL重写规则.htaccess,.htaccess,.htaccess,我需要为下面的URL创建一个重写规则,我需要用GET superglobal传递“id”和widget 是否可以只在重新编写的URL中使用widget参数和值,并且仍然可以正常工作?如果可以,如何操作?简单您可以将其添加到.htaccess中 RewriteEngine On RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?id=$1&widget=$2 [L] 原始URL: http://www.domain.com/index.php

我需要为下面的URL创建一个重写规则,我需要用GET superglobal传递“id”和widget


是否可以只在重新编写的URL中使用widget参数和值,并且仍然可以正常工作?如果可以,如何操作?

简单您可以将其添加到.htaccess中

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?id=$1&widget=$2 [L]
原始URL:

http://www.domain.com/index.php?id=1866&widget=Dangerfield
http://domain.com/index.php?cat=cats&id=12&url=stackoverflow
重写的URL:

http://www.domain.com/1866/Dangerfield.html
http://cats.domain.com/12/stackoverflow.html

这是搜索引擎友好的,你的页面将很容易在带有.html扩展名的搜索引擎中搜索。这比在url末尾添加不利于seo的参数要好

转向辅助子域

原始URL:

http://www.domain.com/index.php?id=1866&widget=Dangerfield
http://domain.com/index.php?cat=cats&id=12&url=stackoverflow
重写的URL:

http://www.domain.com/1866/Dangerfield.html
http://cats.domain.com/12/stackoverflow.html

.htaccess

中重写上述规则的代码。请从您的.htaccess发布您当前的代码。您是否依靠id来显示页面?那么你也需要有身份证。这个问题以前已经回答过6348275623498次了。。。