How can i use RewriteMap directive in htaccess file? When i put it there i get "RewriteMap not allowed here" error.
I know this error will disappear when put it in httpd.conf or virtualhost configuration file. But i want to know is it possible to put it in htaccess or not?
The RewriteMap directive may not be used in <Directory> sections or .htaccess files. You must declare the map in server or virtualhost context. You may use the map, once created, in your RewriteRule and RewriteCond directives in those scopes. You just can't declare it in those scopes.
For example, you can define a RewriteMap as: You would then be able to use this map in a RewriteRule as follows: A default value can be specified in the event that nothing is found in the map: The RewriteMap directive may not be used in <Directory> sections or .htaccess files. You must declare the map in server or virtualhost context.
This should go at the very top of your .htaccess file. At least it should go above ANY other RewriteRules. That is because this uses a loop, until there are no more uppercase characters to convert, it will keep starting at the first HASCAPS:TRUE RewriteRule.
A valid text rewrite map file will have the following syntax: When the RewriteMap is invoked the argument is looked for in the first argument of a line, and, if found, the substitution value is returned. For example, we can use a mapfile to translate product names to product IDs for easier-to-remember URLs, using the following recipe:
From the documentation:
Context: server config, virtual host
so the answer is "no", I'm afraid.
As far as I know it cannot be used in htaccess.
Maybe you could check this out as an alternative: http://savride.wordpress.com/2008/09/09/rewritemap-directive-in-htaccess-file-problem/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With