Mobile app version of vmapp.org
Login or Join
Karen161

: 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}

@Karen161

Posted in: #ModRewrite #QueryString

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Karen161

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme