Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    913
    Thanks
    76
    Thanked 28 Times in 28 Posts

    problem with mod_rewrite

    Good evening all,

    I have a website which has a main navigation with some links being a sub level navigation. All my content files are in one folder called 'content'.

    My menu is layed out as such:
    Code:
    home.tpl
    contact.tpl
    hoa.tpl
          [about]
               who-we-are.tpl
               our-history.tpl
    etc
    
    etc
            [etc]
    Now, when one of the sub level menu links are visited, rather than the url saying: www.mysite.com/home or www.mysite.com/contact, it needs to read as follows: www.mysite.com/about/who-we-are.

    I have rewritten the URL using .htaccess and can get it to work - only with the top-level menu links. When I try adding the 'About' to the URL string, it either sends me to a page which tells me there is a redirect loop or a 404 error.

    Here is my .htaccess:
    Code:
    RewriteEngine on
    RewriteRule ^/?([a-zA-Z-]+)$ index.php?page=$1 [L,QSA]
    RewriteRule ^([a-zA-Z-]+)/([a-zA-Z-]+)/?$ index.php?category=$2&page=$1 [L]
    As stated before, with only 1 $_GET value being passed (the filename), it works perfect, pages load etc. When I try passing the 2 $_GET values ('directory' and filename) - that's when I receive the redirect loop page or 404.

    I am passing the values through the <a> tag as follows: <a href="./PropertyOwner/who-we-are">Who We Are</a>

    I've changed the values around in my second RewriteRule as I want the filename part to be at the very end, but to no avail.

    Can anyone help me fix this problem?

    Can anyone see what I'm doing wrong?

    I thought it may be the QSA flag on the first Rule as that seems to append a string whereas I don't want to append to the end of the string, but insert it before the filename part.

    Thanks very much for your time.

    Kind regards,

    LC.
    Last edited by LearningCoder; 11-18-2013 at 09:22 PM.

  • #2
    Regular Coder LearningCoder's Avatar
    Join Date
    Jan 2011
    Location
    The Pleiades
    Posts
    913
    Thanks
    76
    Thanked 28 Times in 28 Posts
    Sorry for the post, I've figured it out and got it working.

    Thanks anyway!

    Kind regards,

    LC.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •