Hide Url

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mainul
    New Member
    • Sep 2006
    • 51

    Hide Url

    Hi all,
    I would like to hide my url to other for secuiry purpose.

    i have page like:

    http://localhost/cstc/index.php

    i dont want to show my users the page extension.i want to show my user:

    http://localhost/cstc/

    how can i do this?
  • hardikmehta
    New Member
    • Aug 2006
    • 3

    #2
    Hello,

    U do this with the help of .htaccess concept.

    U have to define rule that if url is

    http://localhost/cstc/index.php

    then its give url http://localhost/cstc/.

    Plz. try to use .htaccess concept

    Bye

    Comment

    • pasupathi
      New Member
      • Aug 2006
      • 5

      #3
      I have an option for you..
      just replace your url by duplicate url
      means
      STEP1 -> take the current url by $_SERVER['PHP_SELF']

      STEP2 -> AND REPLACE IT BY YOUR URL(WHICH U LIKE)

      bye
      pasu

      Comment

      • tbb9216
        New Member
        • Sep 2006
        • 16

        #4
        here is the code for an .htaccess file to do what youre asking:
        Code:
        RewriteEngine On
        RewriteBase /
        RewriteCond    %{REQUEST_FILENAME}  !-f
        RewriteCond    %{REQUEST_FILENAME}  !-d
        RewriteRule . /index.php [L]
        this turns on the mod_rewrite engine in apache, tells what base directory to look in, checks the files to see if they exist, and if they dont, it will default to /index.php and you can use the URL as variable using $_SERVER['REQUEST_URI'] and explode

        youll need to do this for each directory you want to have work, otherwise they will all go back to /index.php

        good luck,
        -tim

        Comment

        • mainul
          New Member
          • Sep 2006
          • 51

          #5
          Hi,

          i am working under windows environment and i am novice in php. i am using apche2traid to run my apache server. i could not catch ur solutions. can anyone help me giving the whole sample code?

          Comment

          • tbb9216
            New Member
            • Sep 2006
            • 16

            #6
            http://php.net/htaccess to learn about this in php
            http://us2.php.net/reserved.variables and find info on REQUEST_URI

            since you are using windows, you cant create a .htaccess file because windows wont allow a file starting with a period. so you need to edit your apache.conf file to look for a different file name than .htaccess.

            now that that is ready, creat that file with the info i put in my last post. if your apache document root is c:/php/ then in the .htaccess the / will point to that.

            so what the htaccess file does is turns on apache mod_rewrite, and tells it that if the file in the URI doesnt exist (eg: http://localhost/fakedirectory ), it will display your index.php for your document root. if you HAVE a directory called 'fakedirectory' , it will show the index.php file for that directory. you can place an htaccess file in fakedirectory as well, and start stacking them up so it wouldnt go back to your document root.

            back to using mod_rewrite...

            if you have it point back to / and you go to http://localhost/fakedirectory, it will show /index.php and will set the variable $HTTP_SERVER_VA RS['REQUEST_URI'] to /fakedirectory. if you went to http://localhost/fakedirectory/anotherfake it would set $HTTP_SERVER_VA RS['REQUEST_URI'] to /fakedirectory/anotherfake, which you can then call and explode to break it at the / into seperate vars to work with.

            sorry this is wordy, but i dont know how it cant be

            -tim

            Comment

            • mainul
              New Member
              • Sep 2006
              • 51

              #7
              Hi guys,
              thanks for ur solutions. i got another way to solve the problem. below codes also work. just save the code as index.htm and keep it in the folder. the page name will not show. dont remove the index.php file.

              best regards.



              <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
              "http://www.w3.org/TR/html4/frameset.dtd">
              <HTML>
              <HEAD>
              <TITLE>Custom er Enquiry</TITLE>
              </HEAD>
              <FRAMESET cols="100%">
              <FRAME src="http://localhost/cust/index.php">
              <NOFRAMES>
              <P>This frameset document contains:
              <UL>
              <LI><A href="http://localhost/cust/">A link to mysite</A>
              </UL>
              </NOFRAMES>
              </FRAMESET>
              </HTML>

              Comment

              • gurumoorthi
                New Member
                • Jan 2014
                • 3

                #8
                your html link:
                Code:
                <a href="www.example.com/item/harddisk">Hard disk</a>
                Your .htaccess
                Code:
                RewriteRule ^item/(.*)$ products.php?name=$1
                Your products.php
                Code:
                $name=$_GET['name']

                Comment

                Working...