Perl question

Robert Bushman plug-discuss@lists.plug.phoenix.az.us
Wed, 10 Jul 2002 13:15:10 -0400 (EDT)


I would use Apache's extremely powerful mod_rewrite,
which is a Swiss Army Knife that I have applied to
many problems, for example:

<VirtualHost *>
    DocumentRoot /home/vhosts/color/htdocs
    ServerName stable.traxel.com
    ServerAlias color.traxel.com *.color.traxel.com
    RewriteEngine on
    RewriteLog /usr/local/apache/logs/rewrite_log
    RewriteLogLevel 9

    RewriteCond  %{QUERY_STRING}  (.+)
    RewriteRule  ^/color/$       /?%1 [R]

    RewriteRule  ^/color/$       / [R]

    RewriteCond  %{QUERY_STRING}  (.*)
    RewriteRule  ^/color/(palette.*)        /$1?%1 [R]

    RewriteCond  %{QUERY_STRING}  hue=([0123456789]*).*sat=([0123456789]*).*mode=([^&]*)
    RewriteRule  ^/(palette.*)   /home/vhosts/color/htdocs/palettes/hue-%1/sat-%2/mode-%3/$1 [L]

    RewriteCond  %{QUERY_STRING}  hue=([0123456789]*).*mode=([^&]*).*sat=([0123456789]*)
    RewriteRule  ^/(palette.*)   /home/vhosts/color/htdocs/palettes/hue-%1/sat-%3/mode-%2/$1 [L]

    RewriteCond  %{QUERY_STRING}  mode=([^&]*).*hue=([0123456789]*).*sat=([0123456789]*)
    RewriteRule  ^/(palette.*)   /home/vhosts/color/htdocs/palettes/hue-%2/sat-%3/mode-%1/$1 [L]

    RewriteCond  %{QUERY_STRING}  mode=([^&]*).*sat=([0123456789]*).*hue=([0123456789]*)
    RewriteRule  ^/(palette.*)   /home/vhosts/color/htdocs/palettes/hue-%3/sat-%2/mode-%1/$1 [L]

    RewriteCond  %{QUERY_STRING}  sat=([0123456789]*).*hue=([0123456789]*).*mode=([^&]*)
    RewriteRule  ^/(palette.*)   /home/vhosts/color/htdocs/palettes/hue-%2/sat-%1/mode-%3/$1 [L]

    RewriteCond  %{QUERY_STRING}  sat=([0123456789]*).*mode=([^&]*).*hue=([0123456789]*)
    RewriteRule  ^/(palette.*)   /home/vhosts/color/htdocs/palettes/hue-%3/sat-%1/mode-%2/$1 [L]

#    RewriteCond  %{QUERY_STRING}  hue=([0123456789]*)&sat=([0123456789]*)
#    RewriteRule  ^/palette.html /home/vhosts/color/htdocs/palettes/hue-%1/sat-%2/index.html [L]
#    RewriteRule  ^/(.*)          /home/vhosts/color/htdocs/index.html
</VirtualHost>

On Wed, 10 Jul 2002, Kimi A. Adams wrote:

> We are trying to run a perl program where when you type in a URL or click a
> link for a specific URL, that the path includes a perl program but it's not
> viewed with the .cgi or .pl or other extensions.
>
> I am not sure if this is the appropriate way to ask this.  So, we are doing
> something like this for the
> URL:   www.unitywave.com/testm.cgi?post/username/filename.html  But we
> would like it to look like
> this:  www.unitywave.com/testm/post/username/filename.html  In trying to
> run this from the server:  perl testm.cgi, it works.  It also works when
> you move testm.cgi to testm and run the same command using just testm.  But
> when we go to the website, using that testm instead of the .cgi? it shows
> the program rather than the output like it does on the server.
>
> We want to do this so that a path is shown to the customer, rather than the
> extensions and characters.  However, I am at a draw as to whether this is
> httpd.conf that controls this or if it's the program that is running, i.e.
> perl or cgi.
>
> I would appreciate having responses sent to hotwater@minhthao.com.  That's
> my programmer Minh.  I will be in and out and may not be watching the list.
>
> Thanks.
>
> Kimi Adams
> Unity Wave
> 602-375-5363
>
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.
>
> PLUG-discuss mailing list  -  PLUG-discuss@lists.plug.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>

--------------------------------------------------------------------
 "We need commonsense judges who understand that our rights were
 derived from God. Those are the kind of judges I intend to put on
 the bench." President George W. Bush, 27 June 2002
 http://www.nando.net/politics/story/453192p-3627921c.html

 "no religious Test shall ever be required" Constitution Article 6
 http://www.law.emory.edu/FEDERAL/usconst/art-6.html
--------------------------------------------------------------------