Reputation: 746
I want to map requests as follows
http://www.example.com/my_folder/XYZ/card.jpg
into
http://www.example.com/script_folder/image.php?parameter=XYZ
my directory structure is as follows.
.htaccess
script_folder/
- image.php
Please note that my_folder is a virtual folder which is non-existant. The folder doesn't have any .htaccess in any of it's parent directories. I'm using mod_rewrite.
so far I have managed to write this code in different ways but no luck
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RedirectMatch "^/my_folder/(.*)/card.jpg" "image.php?parameter=$1"
Please help me correct my htaccess
Upvotes: 1
Views: 149
Reputation: 41229
You are mixing mod-alias with mod-rewrite. RedirectMatch is part of a diffrent module (mod alias).
Try this :
RedirectMatch ^/my_folder/(.+)/card.jpg$ /script_folder/image.php?perameter=$1
This will redirect /my_folder/xyz/card.jpg to /script_folder/image.php?perameter=xyz changing the address bar from typed url to a new url. If you want the browser to stay on the typed url, you can use the following mod rewrite based solution :
RewriteEngine on
RewriteRule ^my_folder/(.+)/card\.jpg$ /script_folder/image.php?perameter=$1 [L]
Upvotes: 1