Forum Moderators: phranque
Options -Indexes
RewriteEngine On
DirectoryIndex /cgi-bin/script?do=index [QSA]
RewriteRule ^some/? /cgi-bin/script?do=some [QSA]
RewriteRule ^index\.html /cgi-bin/script?do=index
The htaccess does properly rewrite any access to [foo.com...] to [foo.com...]
Now I'd like to have the ability to add an optional parameter to the passed vars. On the /some dir it works fine, doing things like:
[foo.com...]
which end up as:
[foo.com...]
BUT!
doing [foo.com...]
seems to overwrite the whole query_string! By writing DirectoryIndex /cgi-bin/script?do=index& [QSA] (added &) I was able to debug a bit. My query_string then becomes:
[foo.com...]
Where is the problem in my htaccess? How can I get the optional add=123 added as /cgi-bin/script?do=index&add=123 internally (which QSA should do..)?
Second, DirectoryIndex is dumb as a rock, and is not intended to do fancy query-string-append manipulations.
I suspect the problem is simply that requesting "/" invokes DirectoryIndex, which is replacing both the URL-path and the query string.
If this were my problem, I would stop using DirectoryIndex, and instead, explicitly rewrite directory index path requests to the appropriate filepath, along with any fixed query parameters desired. Using [QSA] on that rule would then allow appending the fixed query data to any query string already present on the client-requested URL-path.
For example,
RewriteRule ^(index\.(html?¦php))?$ /cgi-bin/script?do=index [QSA,L]
(You will need to replace the broken pipe "¦" character with a solid pipe character before use; Posting on this forum modifies the pipe characters.
Jim