use RewriteMap in htaccess file - apache

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?

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/

Related

How to change one url suffix to another in apache?

I hope I can explain this clearly enough, but if not let me know and I'll try to clarify.
I need to configure apache to redirect from one url to another e.g. mySite.com/maven2 should redirect to mySite.com/content/maven2. Do you have any idea how I should do this?
In php you can do this with:
header("LOCATION: mySite.com/content/maven2");
Or you can use a meta refresh...
Take a look at the Redirect Apache directive.
Redirect /maven2 http://example.com/content/maven2
You can use that in either .htaccess or httpd.conf

Create URLs without .php at the end in Apache

I have pages named help.php, about.php and the address will look like:
www.example.com/help.php
I would like to convert it to:
www.example.com/help/
Is there a way to do this without using .htaccess?
You could create a folder called help and move help.php into it as index.php. Do the same thing for about. So you end up with:
help/index.php
about/index.php
Which would both be reachable at just
www.example.com/help/
www.example.com/about/
No there isn't a way to do this without .htaccess.
You could change the 'associated extenstion' for php from .php to something like .p but you would have to update your apache conf file to reflect that (it would just tell the system that .p files should be treated as .php files).
Another alternative would be to stick your help.php file into /help/index.php, which would let you call it as http://domain.com/help/ as the index.php file would be default loaded.
But that isn't what you were asking for...
So short answer is no, cannot be done without .htaccess.

Rewrite map without access to htdocs

I'm on a virtual server so I don't have access to Apache's htdocs; all I have is .htaccess. Is it still possible to do a rewrite map? What kind of workarounds are there?
If you read the documentation you will see that, in the doc field named 'Context', the RewriteMap directive may be used in the server config or in the virtual host config. It is not permitted in directory or .htaccess - to be clear, the answer is No, it is not still possible to do a rewrite map if all you have access to is .htaccess.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritemap
The only 'workaround' would be to define a RewriteCond and RewriteRule for every mapping that you need. These can be defined in .htaccess.
This question was already answered in
use RewriteMap in htaccess file

Apache base URL for subdirectory?

I've got my site in htdocs/mysite which I'll be using to test/develop my website locally. Problem is, now all my URLs in my HTML/CSS need to begin with mysite whereas they won't on the product environment. What's the best way around this? Is there something I can add to httpd.conf to tell it anything in mysite should be relative to mysite? I'm still an apache noob, so please by detailed :)
Can you not just omit the preceding slash on each file reference? i.e.,
.myClass {
background-image: url(images/stuff.png);
}
I'm guessing you want something more substantial. Use an .htaccess file in the /mysite directory. All the info you need is here: RewriteBase

.htaccess mod_rewrite rule not working in Ubuntu

My apologies if this is an easy one. I have Googled it up the hizzy to no avail.
I am running Ubuntu 9.04, Jaunty Jackelope and Apache2. After much trouble, I finally enabled mod_rewrite, and my .htaccess file is attempting to do it's thing, but is failing. This is my setup.
In /etc/apache2/conf.d/ I have a file called apeace-public-html.conf. It reads as follows:
# makes /home/apeace/public_html/ available through /localhost/apeace
Alias /apeace /home/apeace/public_html/
And in /home/apeace/public_html/ I have the following .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^test\.html$ index.html
Also in /home/apeace/public_html/ I have a file named index.html, but I do NOT have a file named test.html. It seems to me that this rewrite should show index.html when I try to access http://localhost/apeace/test.html. However, this is the error I get:
Not Found
The requested URL /home/apeace/public_html/index.html was not found on this server.
So the question is, what in the world am I doing wrong?
Much thanks.
-apeace
Just a guess here, but can you try to make the RewriteRule like ^test.html$ /apeace/index.html
From the error message, it seems it is translating `http://localhost/apeace/test.html to http://localhost/home/apeace/public_html/index.html
Your rewrite rule is working correctly since it's telling you it can't find "index.html". If you went to test.html and it said it can't find "test.html" then your rewrite rule would be at fault.
So what this means is that something else is wrong in your setup, whether it's a bad file or directory name somewhere, or whatever else. Make sure there's nothing basic you're overlooking.
But in answer to your question (especially the title), your htaccess is fine.