I am trying to redirect a URL that looks like this: http://getdotastats.com/sig/28755155.png
To one that looks like this: http://getdotastats.com/sig/?aid=28755155
The first URL being the imaginary one that does not exist.
The regex I cam up with is below. Can you see how to improve it. I lack the necessary know how in forming the regex, so I just made it match groups, and ignore the ones I don't need.
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)sig/(.*)\.(.*)$ index.php?aid=$2 [NC,L]
Can I just throw the above in a .htaccess in the specific directory (/sigs), or are the additional directives required in the main vhost file?
Thanks for helping!
EDIT: Thanks futuretelematics. Using the .htaccess below:
RewriteEngine On
RewriteBase /
RewriteRule testpage\.html http://www.google.com [R]
RewriteRule ^/sig/([0-9]+\.(?:gif|png|jpg))$ index.php?aid=$1 [NC,L]
The testpage redirect to google, but the image redirect throws the following error.
The requested URL /sig/28755155.png was not found on this server.
We must be close. _
Vhost looks like:
DocumentRoot /home/www-dota2
<Directory /home/www-dota2/>
Options Indexes MultiViews +SymLinksIfOwnerMatch
AllowOverride All
Order allow,deny
allow from all
</Directory>