开发者

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

How can i have .htaccess make example from title ? Visitor will type in his browser http://mydomain.tld/somedomain.tld and my whois s开发者_JAVA技巧cript should process http://mydomain.tld/index.php?name=somedomain.tld and return whois result.

Thanks


Use Apache's mod_rewrite.

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

(Not tested, so read up on mod_rewrite if this doesn't work precisely as you'd like it to.)


Try following rule in your .htaccess file:

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

RewriteCond above will prevent infinite redirections.

NC No Case comparison

R=301 will redirect with https status 301
L will make last rule
NE is for no escaping query string
QSA will append your existing query parameters

$1 is your REQUEST_URI

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜