.htaccess http://domain.tld/index.php?name=domain.com to htt



我怎么能有。htaccess使例子从标题?访问者将在浏览器中输入http://mydomain.tld/somedomain.tld,我的whois脚本应该处理http://mydomain.tld/index.php?name=somedomain.tld并返回whois结果。

谢谢

使用Apache的mod_rewrite .

RewriteEngine on
RewriteRule ^(.*)$ http://mydomain.tld/index.php?name=$1 [NC]

(没有测试过,所以如果这不能像你想的那样精确地工作,请阅读mod_rewrite)

在你的。htaccess文件中试试下面的规则:

RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteCond %{QUERY_STRING} !^name= [NC]
RewriteRule ^([^/]*)/?$ /index1.php?name=$1 [L,R=301,NE,QSA]

上面的rewritecsecond将防止无限重定向。

NC No Case comparison

R=301将重定向为https状态301
L将创建最后一条规则
NE用于不转义查询字符串
QSA将附加您现有的查询参数

$1是您的REQUEST_URI

最新更新