Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite dynamic URL problem

         

maximpact

6:52 pm on Apr 6, 2006 (gmt 0)

10+ Year Member



Hi all,

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

jdMorgan

7:31 pm on Apr 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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]

The above is just an example, and important factors may be incorrect. The purpose is only to demonstrate testing the requested query string.

Jim

maximpact

9:40 pm on Apr 6, 2006 (gmt 0)

10+ Year Member



Hi 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

jdMorgan

10:47 pm on Apr 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



for use in httpd.conf or conf.d (as opposed to .htaccess), you'll need a leading slash on the requested URL pattern in the rewriterule:

RewriteRule ^/cgi-bin...

Jim

maximpact

12:03 am on Apr 7, 2006 (gmt 0)

10+ Year Member



Jim,

That works! Thank you kind sir!

Regards, Mark