Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Hide the url.

by Anonymous Monk
on Aug 28, 2004 at 03:30 UTC ( [id://386547]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks.

I have my "c.cgi" in /home/user/public_html/cgi-bin/c.cgi,

there are any way to change the url
http://localhost/~user/cgi-bin/c.cgi?menu=1
to
http://localhost/~user/
or
http://localhost/~user/book/
I'm new... sorry.

Thanks in advance.

Replies are listed 'Best First'.
Re: Hide the url.
by bassplayer (Monsignor) on Aug 28, 2004 at 03:55 UTC
    Place a file in the public_html/ directory called .htaccess, containing one line:
    DirectoryIndex cgi-bin/c.cgi?menu=1

    bassplayer

Re: Hide the url.
by tachyon (Chancellor) on Aug 28, 2004 at 04:12 UTC

    As noted the optimal way is using httpd.conf either directly or via a .htaccess file. You can rediret by placing this as you index.html. It will not hide the URL for you, but will get you to your cgi just by going to localhost/~user/

    <head> <title>Please wait while we redirect you.....</title> <meta http-equiv="refresh" content="0; url=http://localhost/~user/cgi- +bin/c.cgi?menu=1"> <script>window.location.href="http://localhost/~user/cgi-bin/c.cgi?men +u=1"</script> </head>

    cheers

    tachyon

Re: Hide the url.
by jacques (Priest) on Aug 28, 2004 at 03:35 UTC
    You could override it in the httpd conf file.
      In my machine.

      But and if i don't have access to it? This isn't real perl... sorry.

      I'm don't put this questions again.

      Thanks.

        Many hosts allow you to but .cgi files in any directory as long as they have the .cgi extention. Those hosts usually have index.cgi in the list of files for which to look if a directory name is provided as the URL.

        In other words, if you place c.cgi in the directory you named, rename c.cgi to index.cgi, and make sure you there are no index.html, index.htm, etc, in the same directory, it might work without messing with the server's config files or with .htaccess.

        The url would then be
        http://localhost/~user/?menu=1
        or
        http://localhost/~user/book/?menu=1
        unless 1 is the default value for menu.

Re: Hide the url.
by Spidy (Chaplain) on Aug 28, 2004 at 07:08 UTC
    I've encountered the same problem, and this is how I managed to solve it...

    Basically, create a new file called "index.shtml". Leave c.cgi within the cgi-bin directory. Then, inside the index.shtml file, put:

    < !--#include virtual="/cgi-bin/c.cgi" -- >

    The stuff in the quotations, as could probably be guessed, is the path to your CGI script. However, this method will make it show up when you go to the directory with index.shtml inside of it. (There must be no other "index" files in the directory, I'm pretty sure) The CGI will appear to be the home/main page. However, once a link is taken to itself, like "c.cgi?menu=1", it will show up as "cgi-bin/c.cgi?menu=1".

    Hope I was helpful,
    Spidy

    P.S.-I'm fairly certain that inside the URL in the include, you can have something like "c.cgi?menu=1". You're also going to have to get rid of the spaces between < and !, and - and >.
Re: Hide the url.
by osama (Scribe) on Aug 28, 2004 at 09:46 UTC
    if using Apache, you can use mod_rewrite, in a .htaccess file, write something like:
    RewriteEngine on RewriteBase /~user/ RewriteRule ^book /~user/cgi-bin/c.cgi?menu=1

    you can learn more about mod_rewrite at apache's documentation, or by Googling.

Re: Hide the url.
by doowah2004 (Monk) on Aug 28, 2004 at 05:34 UTC
    The easiest way (but not nearly as elegant) is to use frames. and have the code target the main frame, then only the frame url will be displayed.

    You could also use redirect in .htaccess. Here is a decent tutorial on .htaccess

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://386547]
Approved by NetWallah
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-23 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found