Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use RewriteMap in htaccess file

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?

like image 884
hd. Avatar asked Oct 20 '10 07:10

hd.


People also ask

Can I use rewritemap directive in <directory> section or <htaccess>?

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.

How to use rewritemap in a rewriterule?

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.

Where do I put the true rewriterule in a htaccess file?

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.

What is a valid text rewrite map file?

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:


2 Answers

From the documentation:

Context: server config, virtual host

so the answer is "no", I'm afraid.

like image 89
Bobby Jack Avatar answered Sep 29 '22 09:09

Bobby Jack


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/

like image 22
kapa Avatar answered Sep 29 '22 10:09

kapa