Apache rewrite rule - prevent rewritten URL appearing in browser URL bar

前端 未结 1 786
耶瑟儿~
耶瑟儿~ 2021-01-23 02:18

I have a rewrite rule which is looking for a particular URI. When it matches the particular URL it rewrites it with a proper file path so the required content can be found. It t

1条回答
  •  孤街浪徒
    2021-01-23 02:28

    From the mod_rewrite documentation:

    If an absolute URL is specified, mod_rewrite checks to see whether the hostname matches the current host. If it does, the scheme and hostname are stripped out and the resulting path is treated as a URL-path. Otherwise, an external redirect is performed for the given URL. To force an external redirect back to the current host, see the [R] flag below.

    If you rewrite the request to a fully qualified URL (that is, anything starting with http://, https://, etc) that doesn't match your ServerName, then mod_rewrite will issue an HTTP redirect, which will cause the client browser to request the resource from the new location.

    If you're not trying to switch between http and https you can use a proxy rule (the P flag) to have Apache make the request on behalf of the client and return the result, thus masking the rewritten URL.

    However, if you're trying to upgrade from http to https (or the other way around), this will always require a client redirect.

    0 讨论(0)
提交回复
热议问题