Is there a way to make a URL appear as if it's one directory higher?

Discussion in 'Apache' started by CineWeekly.com, Jan 11, 2011.

  1. CineWeekly.com

    CineWeekly.com Greenhorn

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #21
    Ah, I understand. They don't have to add a new line of code for every post though do they? I'm assuming they can set it up with wildcards or something.
     
    CineWeekly.com, Jan 15, 2011 IP
  2. Riquez

    Riquez Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #22
    yes.

    Here is an example rule for our website product page. There are 100's of products, but we only have 1 page to display a product.

    RewriteRule ^([a-z]{2})/([a-z0-9_-]+)/(_[a-z0-9_-]+)?/?([a-z0-9_-]+)/([a-z0-9_-]+)/?([a-z0-9_-]+)?/?$ product.php?language=$1&cat=$2&subcat=$3&make=$4&model=$5&pg=$6

    The URL would be like this

    domain.com/en/bags/prada/mens-black-leather

    Each set of brackets ([a-z]{2}) etc indicates some piece of info in the url like "/bags/" there are 6 parts in total, but some of them are optional.

    The right side of the rule is showing what the actual URL would be with no rewrite
    domain.com/product.php?language=en&cat=bags&make=prada&model=mens-black-leather

    With this we can give a sensible url that shows a logical breakdown of where you are
    /en/bags/prada/ = english, bags section, prada

    But in actual fact we dont have any folders on our website other than images folder.
    we have

    index.php
    category.php
    product.php
    basket.php
    checkout.php

    & thats essentially it, other than things like contact, help etc.
     
    Riquez, Jan 15, 2011 IP
  3. CineWeekly.com

    CineWeekly.com Greenhorn

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #23
    Got it. Do you know any good beginner tutorials for databases? I think I can keep doing what I'm doing and have a successful site without a database but it may be work looking into.
     
    CineWeekly.com, Jan 15, 2011 IP
  4. Riquez

    Riquez Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #24
    Your site is saving new pages each time you write an article instead of using a database, its a bit of an old school way of doing things, but nothing wrong with that. You just dont have the flexibility a database would give.

    If you're using cPanel then you probably have the ability to use mysql (database) & phpmyadmin (web admin for mysql) with your web host.
    I dont know how your website works, but i assume you have an admin system for writing new articles & setting preferences. Does it support mysql?
    If so then you are probably good to start using a database.
    In this situation, you dont really need to know much about the database, your web admin will set up whats needed & you continue to write articles as normal. but now they are saved in the database.

    You will have the issue of moving all your existing articles etc into database format & that could be quite a task. but perhaps your website admin has an option to convert it all?
    If not, you might be better sticking with what you have for now & then when you plan to have a re-vamp, new site etc, that would be a good time to change.

    I dont really know any database tutorials, im sure there are plenty out there. MySQL is probably the most popular & works well with PHP.
    Dont dive into the official MySQL website though, its very technical.
    Actually im not the person to ask about things like cPanel & website CMS because I only program custom systems from scratch.
     
    Riquez, Jan 15, 2011 IP
  5. claytantor

    claytantor Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #25
    This is the right answer.
     
    claytantor, Jan 15, 2011 IP
  6. CineWeekly.com

    CineWeekly.com Greenhorn

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #26
    Haha, no it's not claytantor, we're past that.


    By web admin do you mean on the hosting side? Because I'm the only one working on my site on my end. I set up a database for my forum but that was based off a YouTube tutorial and I followed it to the T so I don't know what I was doing exactly. My host supports mysql and phpadmin (used mysql for the forum I believe). I tried finding tutorials on databases before but it's a catch-22 they all talk more like a refresher course than something for a complete beginner.
     
    CineWeekly.com, Jan 15, 2011 IP