如何让.htaccess从title生成示例?访问者将在他的浏览器中输入http://mydomain.tld/somedomain.tld,我的whois脚本应该处理http://mydomain.tld/index.php?name=somedomain.tld并返回whois结果。
谢谢
发布于 2011-04-15 06:15:59
使用Apache的mod_rewrite。
RewriteEngine on
RewriteRule ^(.*)$ http://mydomain.tld/index.php?name=$1 [NC](没有经过测试,所以如果它不能像您希望的那样工作,请阅读mod_rewrite。)
发布于 2011-04-15 11:28:23
在您的.htaccess文件中尝试以下规则:
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteCond %{QUERY_STRING} !^name= [NC]
RewriteRule ^([^/]*)/?$ /index1.php?name=$1 [L,R=301,NE,QSA]上面的RewriteCond将阻止无限重定向。
NC无案例比较
R=301将重定向并显示https状态301
L将制定最后一条规则
NE用于不转义查询字符串
QSA将追加您现有的查询参数
$1是您的REQUEST_URI
https://stackoverflow.com/questions/5670334
复制相似问题