Forum Moderators: phranque
I have a problem configuring mod_write to rewrite dynamic URLs on my server. I am a Photographer and I am switching from one portfolio system to another. I have tested that mod_rewrite actually works on my server by redirecting one static page to another without any problems :
RewriteEngine on
RewriteRule photo1\.html photo2.html
But I seem to be having problems with the following :
RewriteEngine on
RewriteRule direct=Landscapes cpg144/thumbnails.php?album=2 [R=301,L]
I've tried it various ways, including :
RewriteEngine on
RewriteRule ^cgi-bin/imageFolio.cgi\?direct=Landscapes$ cpg144/thumbnails.php?album=2 [R=301,L]
but with no joy. I am sure there is an obvious error somewhere that I am not seeing. I have spent 2-3 hours looking over the help files with no joy so any help given would be greatly appreciated.
Regards, Mark
Welcome to WebmasterWorld!
Query strings are not part of a URL, they are data appended to a URL to be passed to the resource *at* that URL. Therefore, query strings are not directly visible to RewriteRule.
You need to use RewriteCond, and examine the %{QUERY_STRING} variable. Something like this:
RewriteCond %{QUERY_STRING} direct=Landscapes
RewriteRule ^cgi-bin/imageFolio\.cgi$ http://www.example.com/cpg144/thumbnails.php?album=2 [R=301,L]
Jim
Thank you for your reply. I tried what you suggested but it did not work. Perhaps there is some elementary configuration problem with my Apache installation. I have the following set :
AllowOverride FileInfo Options AuthConfig
And the following relevant info in my Virtual Host settings in Apache :
Options Includes ExecCGI Indexes FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} direct=Landscapes
RewriteRule ^cgi-bin/imageFolio\.cgi$ /cpg144/thumbnails.php?album=2 [R=301,L]
Is there another way I can try? Thanks.
Regards, Mark