I have a multilingual web application that depends on a language code being in the URL.
Example:
example.com/zh-hans/title
The client now wants a new structure:
example.com/cn/title
The problem is the application was built around using zh-hans
. As that part of the URL is an argument that is necessary for the application to work properly, changing it would break the application. Also, it's not possible to change this in the application to accommodate. This would take 100s of hours of work to undo.
Is it possible for the browser to show one URL while behind the scenes data is served from the other URL and thus preserve functionality?
The Apache documentation state that:
Assume we have recently renamed the page foo.html to bar.html and now want to provide the old URL for backward compatibility. However, we want that users of the old URL even not recognize that the pages was renamed - that is, we don't want the address to change in their browser.
https://httpd.apache.org/docs/2.4/rewrite/remapping.html (From old to new (internal))
Then, would the solution to this issue be as simple as this?
RewriteEngine on
RewriteRule "^/zh-hans/(.+)" "/cn/$" [PT]