简体   繁体   中英

Htaccess Redirection without changing browser url

When users come to my site, they use this format of url ("demo" has no importance here) : https://example.com/page/demo-558

My system may redirect it to this format https://example.com/?view=test&page=658

But I don't want the users to see URL change in the browser, it must be invisible. I searched for hours but nothing seems to works ! Here is my current rule :

RewriteRule ^page/(.+)-([0-9]+)$ /index.php?view=test&page=$2

How should the browser display a dynamic page with parameters without 'knowing' the parameter?

I think you are not searching for a (transparent) rewrite, more for a reverse (not transparent) proxy. The URL will be handled between http server and proxy, the browser gets the 'simplyfied' URL.

  1. Browser send to Server: /page/demo-558
  2. Server rewrite to /?view=test&page=658
  3. Server delivers content to ReverseProxy with /?view=test&page=658
  4. ReverseProxy delivers content to browser with /page/demo-558

The ReverseProxy is part of the http-Server

Explained with pictures: https://www.akadia.com/services/apache_redirect.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM