I have dynamically created images on my index.html page. I want the user to be able to click on them and be redirected to pic_page.html.
The image links on the index.html page look like this:
//<a href="http://mysite.com/index.html?bluepart=view&blueimage=29">//
My redirect code in .htaccess looks like this:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{IMAGE} ^bluepart=view&blueimage=([0-9]+)$
RewriteRule ^/index.html$ /pic_page.html [R=301,L]
</IfModule>
The redirect does not work. When I scroll down index.html and click an image, the page jumps back to the top of the index.html page.
Test links to pic_page.html such as this work fine:
//<a href="http://mysite.com/pic_page.html?bluepart=view&blueimage=23">test</a>//
Any idea why the redirect won’t work, and just jumps to the top of index.html?
Thanks,
Darrell
1. Question: Why don’t you use proper link in first place? You could easily avoid all these problems.
2. Answer to your question: what
%{IMAGE}supposed to do? I have no idea what%{IMAGE}means — it is definitely not a standard mod_rewrite variable.Change it to
%{QUERY_STRING}then rule will work as intended:P.S.
I do not know why do you use redirect here (301 Permanent Redirect) and therefore I may be wrong, but I would use rewrite (internal redirect) instead of actual redirect (301, external redirect). For this — replace
[R=301,L]by[L]Also, because this rule (as you have stated) is placed in .htaccess, no need for leading slash in rewrite pattern
^/index.html$— should be just^index.html$(that leading slash is required IF rule is placed in Apache config file / virtual host context).