.htaccess RewriteRule to path without changing URL

后端 未结 2 604
轻奢々
轻奢々 2020-11-30 13:51

So, I\'ve this problem:

  1. Base Website located at http://example.com/
  2. Second Website located at http://example.com/web2/
2条回答
  •  一个人的身影
    2020-11-30 14:19

    This is a pretty simple rewrite. In the htaccess file in your document root, just add the following:

    RewriteEngine On
    RewriteRule ^alternative-url-web2/?(.*)$ /web2/$1 [L]
    

    Unlike a redirect, which makes the browser/client send a new request for a new URL (thus changing what's in the browser's location bar), a rewrite happens entirely on the server's side.

提交回复
热议问题