Web Analytics Made Easy -
StatCounter Cloaking ???? - CodingForum

Announcement

Collapse
No announcement yet.

Cloaking ????

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cloaking ????

    Ok here is my final problem

    i want it so if a user types http://www.matesonline.co.uk/username <-- replace username with the name of the person they want to view
    it will redirect to http://www.matesonline.co.uk/viewpro...p?vmpid=userid

    i want it to query the database and depending on the username will insert the userid.


    not sure if i explained it properly but those experienced will understand what i mean.

    this will be the last time i require help


    thanks in advance
    ==========================
    Find A Date Or Just Friends
    @ http://www.matesonline.co.uk ==========================

  • #2
    Re: Cloaking ????

    i want it so if a user types http://www.matesonline.co.uk/username (replace username with the name of the person they want to view)
    it will redirect to http://www.matesonline.co.uk/viewprofile.php?vmpid=userid
    Make an .htaccess file, switch the RewriteEngine on and use this directive to redirect (assuming your server does support htaccess and mod_rewrite):

    Code:
    RewriteEngine On
    RewriteRule ^(http://www.matesonline.co.uk)/([a-zA-Z0-9_]*)/?$ $1/viewprofile.php?vmpid=$2
    i want it to query the database and depending on the username will insert the userid.
    PHP Code:
    $sql "SELECT * FROM your_user_table WHERE vmpid = ".$_GET['vmpid'];
    $res mysql_query($sql); 
    ... you'll be able to go on?
    if not, explain exactly what you want to do.

    not sure if i explained it properly but those experienced will understand what i mean.
    You'll make it easier for us if you explain it as detailed as possible. Thx.

    this will be the last time i require help
    You're sure? ;-)

    Greetz
    piz
    www.united-scripts.com
    www.codebattles.org

    Comment


    • #3
      hi Piz.

      im not exactly sure how to make a .htaccess file.

      also just so you are aware incase you thougth differently i dont want to restrict access to a page if they dont type domain.com/username


      i cant believe i admitted i dont know how to make a .htaccess file
      never used them before

      would prefer to do it soley in php if possible


      thanks for your help so far
      ==========================
      Find A Date Or Just Friends
      @ http://www.matesonline.co.uk ==========================

      Comment


      • #4
        im not exactly sure how to make a .htaccess file.
        create plain text File namend .htaccess -> Open your ftp client -> connect -> upload in this directory. ;-)

        also just so you are aware incase you thougth differently i dont want to restrict access to a page if they dont type domain.com/username
        You won't restrict anything. But it would be recommanable to add a character when typing http://...../username to difference the usernames from the subfolders (if you have subfolders).

        i cant believe i admitted i dont know how to make a .htaccess file
        never used them before
        --> http://www.sitepoint.com/article/910/1
        --> http://www.zend.com/zend/spotlight/searchengine.php
        --> http://www.freewebmasterhelp.com/tutorials/htaccess/1
        --> http://httpd.apache.org/docs/misc/rewriteguide.html

        would prefer to do it soley in php if possible
        You won't be able. You try to open a file in the browser which doesn't exist. There can't be executed any php code then.

        There are three possibilities...
        1) create a directory for each user with an index file which redirects to the script you want to execute (i wouldn't...)
        2) you redirect the 404 error document to your script to execute (i wouldn't, neither... that's very very very ugly, and fills up the loggfiles with useless entries...)
        3) you change the url by the apache server with above mentioned mod_rewrite

        Saludo
        piz
        www.united-scripts.com
        www.codebattles.org

        Comment


        • #5
          solely in PHP heh.

          Maybe i'm just not experienced enough, but i'd assume that the webserver then starts looking for a file like http://www.matesonline.co.uk/username/index.*
          so unless you actually create a real directory for each user, your webserver will throw a 'file not found'.

          I tink you'll need the mod_rewrite to point the webserver to the actual file that you need to proces the requested url (not sure if the http://www.matesonline.co.uk/username is stored in any ofter the server-variables, but that is easy to found out by printing them all).
          If you get that far, then it's just a matter of creating an array for the url (use explode("/', xxxxx) tobuild the array and then grab the last element or use a dirname() on the last element if there is a filename added to the http://www.matesonline.co.uk/username
          You then use that value inside the where clause of your selec and redirect (using header(location : ...) to the page.

          Lotts of if's ...I'd need some experimenting to see if it'spossible, but i fear that the first step will already fail on an error 404 ...

          <edit>posts crossed (got distracted). seams like we both agree that it's probably a no-go</edit>
          Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

          Comment


          • #6
            ok...

            created a blank .htaccess file and uploaded it

            where do i put
            --------------------------------------------------------------------------------RewriteEngine On
            RewriteRule ^(http://www.matesonline.co.uk)/([a-zA-Z0-9_]*)/?$ $1/viewprofile.php?vmpid=$2

            ?
            ==========================
            Find A Date Or Just Friends
            @ http://www.matesonline.co.uk ==========================

            Comment


            • #7
              created a blank .htaccess file and uploaded it

              where do i put

              Code:
              RewriteEngine On
              RewriteRule ^([url]http://www.matesonline.co.uk[/url])/([a-zA-Z0-9_]*)/?$ $1/viewprofile.php?vmpid=$2
              In the htaccess file.
              Have a look at the tutorials, before. It'll help you.
              And be aware that there are provider which don't support all htaccess directives or don't support mod_rewrite.
              www.united-scripts.com
              www.codebattles.org

              Comment


              • #8
                ok thanks

                i'll let you know how i get on.
                hosting the site on one of the servers at work so i can always change it

                thanks both of you for your help ...........again
                ==========================
                Find A Date Or Just Friends
                @ http://www.matesonline.co.uk ==========================

                Comment


                • #9
                  having a problem
                  i have had to add the following line to my httpd.conf file because it didnt exist
                  AddModule mod_rewrite.c
                  LoadModule mod_rewrite.so etc etc already existed so thats ok

                  Added
                  <IfModule mod_rewrite.c>
                  RewriteEngine on
                  RewriteRule ^(http://www.matesonline.co.uk)/([a-zA-Z0-9_]*)/?$ $1/viewprofile.php?vmpid=$2
                  </IfModule>
                  to my httpd.conf like instructed @ http://www.sitepoint.com/article/guide-url-rewriting/2

                  but when i kill apache and attampt to restart it wont start back up .. if i remove AddModule etc it will start back up but the REWRITE DOESNT WORK

                  if i didnt have a shaved head i'd pull my hair out

                  please help
                  ==========================
                  Find A Date Or Just Friends
                  @ http://www.matesonline.co.uk ==========================

                  Comment


                  • #10
                    ok its 12:30 am and i still cant figure this one out. have loked through all the guides but cant work out bhy i cant get it to work

                    anyone throw any light on this ?
                    ==========================
                    Find A Date Or Just Friends
                    @ http://www.matesonline.co.uk ==========================

                    Comment


                    • #11
                      Not dived into this area much, but I'm guessing the first $ is causing the problems

                      RewriteRule ^(http://www.matesonline.co.uk)/([a-zA-Z0-9_]*)/?$ $1/viewprofile.php?vmpid=$2

                      Comment


                      • #12
                        Originally posted by Nightfire
                        Not dived into this area much, but I'm guessing the first $ is causing the problems

                        RewriteRule ^(http://www.matesonline.co.uk)/([a-zA-Z0-9_]*)/?$ $1/viewprofile.php?vmpid=$2
                        It shouldn't. 'Cause it is not the first $, it's the last one of the pattern string and means "end of string".
                        After the space the replace string starts.

                        But you can try it without anyway.
                        www.united-scripts.com
                        www.codebattles.org

                        Comment


                        • #13
                          still not doing anything
                          i have the following line in my httpd.conf
                          LoadModule rewrite_module modules/mod_rewrite.so

                          and in the .htaccess file i have teh following
                          RewriteEngine On
                          RewriteRule ^(http://www.matesonline.co.uk)/([a-zA-Z0-9_]*)/?$1/viewprofile.php?vmpid=$2


                          tried the last bit woth 1 & 2 $ but nothing... what am i doing wrong ?
                          ==========================
                          Find A Date Or Just Friends
                          @ http://www.matesonline.co.uk ==========================

                          Comment


                          • #14
                            Originally posted by sitami
                            RewriteEngine On
                            RewriteRule ^(http://www.matesonline.co.uk)/([a-zA-Z0-9_]*)/?$1/viewprofile.php?vmpid=$2
                            There is a space missing, before $1.

                            The only thing i can recommend you, is to read the tutorials and start with very very simple RewriteRules without RegExp to check if mod_rewrite is working and how it is working.

                            A simple one:

                            RewriteRule /start /myIndex.html

                            This should redirect you to myIndex.html in the root direcotry of your webserver if you type http://your_hoste/start in.
                            www.united-scripts.com
                            www.codebattles.org

                            Comment

                            Working...
                            X