: Apache mod_rewrite problem with adding a query string on an internal rewrite I need to replace /xyz with /index.html?dh=xyz. I use the following config in httpd.conf: RewriteCond %{QUERY_STRING}
I need to replace /xyz with /index.html?dh=xyz. I use the following config in httpd.conf:
RewriteCond %{QUERY_STRING} "!dh"
RewriteRule "^/(.*)$" "/index.html?dh=" [R]
This works perfectly if [R] flag is present, but if I remove it, the query string is missing from the resulting URL. I would like to use the internal rewrite (no [R]). Any ideas?
More posts by @Karen161
1 Comments
Sorted by latest first Latest Oldest Best
Here is the entire index.html: <script> console.log(self.location); </script>
Well, that's the problem. You won't be able to see the rewritten URL (and query string) from client-side JavaScript.
An internal rewrite is entirely internal to the server. JavaScript only sees the initial URL of the request - the URL displayed in the browsers address bar. eg. /xyz.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.