ANy programmers here know how to do an if/else??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • clickhappy
    Confirmed User
    • Mar 2004
    • 4027

    #1

    ANy programmers here know how to do an if/else??

    I just need something that says if /2/ appears in a url, then change it to /3/.
    I want it to go to a different folder.
    Anyone know how to do this with php, or javascript?
    is that going to slow down the page a lot?
    Last edited by clickhappy; 07-19-2006, 08:41 PM.
  • BigBen
    Confirmed User
    • Nov 2004
    • 2299

    #2
    May want to use mod_rewrite.

    Comment

    • Sly
      Let's do some business!
      • Sep 2004
      • 31377

      #3
      I haven't done much programming in a long time and I wasn't the best, but I think for something like that you would be much better off using regular expressions, not if/else.
      Vacares - Web Hosting, Domains, O365, Security & More - Paxum and BTC Accepted

      Windows VPS now available
      Great for TSS, Nifty Stats, remote work, virtual assistants, etc.
      Click here for more details.

      Comment

      • woj
        <&(©¿©)&>
        • Jul 2002
        • 47880

        #4
        Originally posted by BigBen
        May want to use mod_rewrite.
        Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
        Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
        Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

        Comment

        • Nookster
          Confirmed IT Professional
          • Nov 2005
          • 3744

          #5
          Need to use mod_rewrite for that one.
          The Best Affiliate Software, Ever.

          Comment

          • SmokeyTheBear
            ►SouthOfHeaven
            • Jun 2004
            • 28609

            #6
            <?php

            $this = $PHP_SELF;
            if (preg_match("/\/2\//", $this)) {
            echo "folder found";
            }
            else {
            echo "folder not found";
            }
            ?>

            if the folder name your looking for is 2 like

            www.yoursite.com/nastylady/2/something.html
            hatisblack at yahoo.com

            Comment

            • SmokeyTheBear
              ►SouthOfHeaven
              • Jun 2004
              • 28609

              #7
              whoops i think i misunderstood your question actually. you want to rewrite all urls on the page or if the php itself is in a folder called /2/ ?
              hatisblack at yahoo.com

              Comment

              • madawgz
                8.8.8.8
                • Mar 2006
                • 30509

                #8
                Originally posted by SmokeyTheBear
                <?php

                $this = $PHP_SELF;
                if (preg_match("/\/2\//", $this)) {
                echo "folder found";
                }
                else {
                echo "folder not found";
                }
                ?>

                if the folder name your looking for is 2 like

                www.yoursite.com/nastylady/2/something.html
                something else to learn
                TAEMDLRMSKRJIXMRLSMRJ.

                Comment

                • clickhappy
                  Confirmed User
                  • Mar 2004
                  • 4027

                  #9
                  Originally posted by SmokeyTheBear
                  whoops i think i misunderstood your question actually. you want to rewrite all urls on the page or if the php itself is in a folder called /2/ ?
                  no
                  when the url says http://www.whatever.com/porn/2/
                  I want to rewerite it to say http://www.whatever.com/porn/3/ automatically because there are a ton of links

                  Comment

                  • adultseo
                    Confirmed User
                    • Jun 2005
                    • 365

                    #10
                    • is the /porn/ directory a real directory?
                    • is /porn/ the only directory in wich you need /2/ rewritten to /3/?
                    • would you like to use Mod rewrite to simulate as if /2/ is /3/, so it will look to the browser as if you are on /2/ but you see /3/, or do you want to have a redirect in wich I would advice to use a 301 redirect so that the possibly indexed /2/ directory it's PR (SE value) is transfered to /3/


                    Let me know ;)

                    Best Regards,
                    Adult SEO
                    The key to get ranked one in Google is to provide the best.

                    Comment

                    • BigBen
                      Confirmed User
                      • Nov 2004
                      • 2299

                      #11
                      Drop this in your .htaccess in the /porn/ directory for a redirect...

                      RewriteEngine On
                      RewriteRule ^2/$ /porn/3/ [R]

                      Comment

                      • adultseo
                        Confirmed User
                        • Jun 2005
                        • 365

                        #12
                        In that case better use:
                        Code:
                        RewriteEngine on
                        rewriterule ^2/$ http://www.domain.com/ [r=301,L]
                        rewriterule ^2/(.*)$ http://www.domain.com/$1 [r=301,L]
                        This is better for SEO in case your old /2/ directory has been indexed.
                        The key to get ranked one in Google is to provide the best.

                        Comment

                        • Kimo
                          ...
                          • Jan 2006
                          • 11542

                          #13
                          php sucks inrl
                          ...

                          Comment

                          Working...