301 redirect

前端 未结 3 1268
傲寒
傲寒 2021-01-23 09:46
  1. How do i redirect a url to domain . eg. http://www.mydomain.com/index.php=HairThing --> http://www.mydomain.com

  2. How do i redir

3条回答
  •  余生分开走
    2021-01-23 10:13

    See also: Hidden features of mod_rewrite

    #1
    RewriteRule /index.php=HairThing$ http://www.mydomain.com [R=301]
    
    #2
    RewriteCond %{HTTP_HOST} ^mydomain.com 
    RewriteRule .*   http://www.mydomain.com [R=301] 
    

    However, example case 1, as said by Greg, will always put the / on if it is without a uri.

    mydomain.com  # impossible 
    mydomain.com/ # possible
    mydomain.com/foo  #possible
    mydomain.com/foo/ #possible
    

提交回复
热议问题