.htaccess

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mrozko

    .htaccess

    Hi,

    I hope my message is not "out of topic"....

    I would like to make "clean URLs" on my website....

    Is it possible to make something like this:

    orig. URL: /inde.php?mcat=1 &subcat=2

    clean (nice) URL: /tv/lcd/

    where mcat(1)="tv" and subcat(2)="lcd"

    Thanks for any help....

    Best,
    Marian
  • mrozko

    #2
    Re: .htaccess

    Jensen,

    thank you very much for your simple solution. I was looking for very
    complicated and one-step solution using .htaccess, unfortunately.. ..

    Thanks again :)

    Marian

    Comment

    • mrozko

      #3
      Re: .htaccess

      Hi,

      I have one more question:

      is it possible to use "loop" in the .htaccess:

      let's say $mcat[1]="tv", $mcat[1][1]="lcd", $mcat[1][2]="crt", $mcat[1]
      [3]="accessories", ... (it means it is 2D array)

      I would like to do this:
      /tv/lcd/ /index.php?mcat= 1&subcat=1
      /tv/crt/ /index.php?mcat= 1&subcat=2
      /tv/accessories/ /index.php?mcat= 1&subcat=3
      ....

      note: $mcat has 10 items (0,...,10) ---- for each item there are at
      least 5 subitems...

      must I type one line for one "combinatio n" of items & subitems? or is
      it possible to "loop" through this?

      maybe this question is "stupid" and I have to recode my scripts....

      please, can you give me any idea for doing this? what is your opinion
      about this?

      thank you very much, in advance, for your (maybe completely different)
      solution....

      best,
      marian

      Comment

      • Rzzap

        #4
        Re: .htaccess

        mrozko wrote:
        Hi,
        >
        I have one more question:
        >
        is it possible to use "loop" in the .htaccess:
        >
        let's say $mcat[1]="tv", $mcat[1][1]="lcd", $mcat[1][2]="crt", $mcat[1]
        [3]="accessories", ... (it means it is 2D array)
        >
        I would like to do this:
        /tv/lcd/ /index.php?mcat= 1&subcat=1
        /tv/crt/ /index.php?mcat= 1&subcat=2
        /tv/accessories/ /index.php?mcat= 1&subcat=3
        ....
        >
        note: $mcat has 10 items (0,...,10) ---- for each item there are at
        least 5 subitems...
        >
        must I type one line for one "combinatio n" of items & subitems? or is
        it possible to "loop" through this?
        >
        maybe this question is "stupid" and I have to recode my scripts....
        >
        please, can you give me any idea for doing this? what is your opinion
        about this?
        >
        thank you very much, in advance, for your (maybe completely different)
        solution....
        Any kind of more elaborate programming is quite difficult or next to
        impossible in .htaccess.

        I for one choose to keep it simple, and move all more elaborate :
        -------.htaccess--------------
        RewriteCond %{REQUEST_URI} !-f
        RewriteCond %{REQUEST_URI} !-d
        RewriteRule .* rewriter.php
        ------------------------------
        -------rewriter.php-----------
        $path = explode('/',parse_url($_S ERVER['REQUEST_URI'], PHP_URL_PATH));
        foreach($path as $path){
        //do you own logic here
        }
        ------------------------------

        Keeps it very flexible on the PHP side, and you can use any URL you
        please. The drawback is YOU are responsible for proper status headers
        (Not Found being one of the more important among them), so the load on
        the server will increase, as instead of a very fast HTTP server
        immediately returning codes, a PHP process (and possble database
        connections etc.) has to be started.
        --
        Rik

        Comment

        • Rzzap

          #5
          Re: .htaccess

          Rzzap wrote:
          foreach($path as $path){
          Hmmm, that would be stupid :P

          Comment

          • Rzzap

            #6
            Re: .htaccess

            Rzzap wrote:
            -------.htaccess--------------
            RewriteCond %{REQUEST_URI} !-f
            RewriteCond %{REQUEST_URI} !-d
            RewriteRule .* rewriter.php
            ------------------------------
            Pompom, errors on errors :)

            RewriteCond %{REQUEST_FILEN AME} !-f
            RewriteCond %{REQUEST_FILEN AME} !-d

            Comment

            • Jerry Stuckle

              #7
              Re: .htaccess

              mrozko wrote:
              Hi,
              >
              I hope my message is not "out of topic"....
              >
              I would like to make "clean URLs" on my website....
              >
              Is it possible to make something like this:
              >
              orig. URL: /inde.php?mcat=1 &subcat=2
              >
              clean (nice) URL: /tv/lcd/
              >
              where mcat(1)="tv" and subcat(2)="lcd"
              >
              Thanks for any help....
              >
              Best,
              Marian
              >
              Yes, it's a bit off topic here, as it isn't a PHP question.

              You will get much better answers from alt.apache.conf iguration.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              Working...