.htaccess: Redirect without changing url

后端 未结 3 1118
暗喜
暗喜 2020-12-09 08:51

I would like to have a URL be redirected to a different page on the same domain but without the browser changing the URL. So the page www.mydomain.co.uk/tour/ s

3条回答
  •  北海茫月
    2020-12-09 09:33

    Because you provide a full URL in your rewrite rule it is automatically treated as a redirection. Replace the full URL with just a slash and it should work, i.e.:

    RewriteCond %{REQUEST_URI} ^/tour
    RewriteRule ^(.*)$ / [P] 
    

    You can even shorten it down to:

    RewriteEngine on
    RewriteRule ^/?tour.* / [P]
    

提交回复
热议问题