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 6 of 6
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with .htaccess

    Hello! I have a problem with .htaccess and I will be very happy if you could help me!
    In index.php I have
    Code:
    include('horizontalmenu.php')
    
    if ($_GET['page']=='teams' and isset($_GET['name']))
    {
            include('includes/teams.php');
    }
    else
    .......
    ************************
    In horizontalmenu.php I have
    Code:
    $page='teams'
    and $name is not a constant, it could be AC Milan, Juventus Turin etc. and I try to load the page teams.php , because the page ACMilan.php doesn't exist 
    
    <a href="'.$page.'/'.$name.'.html">...</a>
    **************************
    In .htaccess i have
    Code:
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9]+).html$  index.php?page=$1&name=$2
    RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9]+)/.html$  index.php?page=$1&name=$2
    **************************
    In teams.php I have:
    Code:
    .......
    **************

    So i try to change a page like this: calcioitalia2/index.php?page=teams&name=A.C. Milan in calcioitalia2/teams/A.C. Milan.html

    But doesn't work! I have this message:
    The requested URL /calcioitalia/teams/A.C. Milan.php was not found on this server.

    What can i do? Maybe i don't know to configure these files! Thank you very much for your help!

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Not a thing to do with PHP.
    Your pattern doesn't include spaces or periods so add .\s to the character class. Also you don't need two patterns, just use the second and use /? instead of just /.

  • #3
    New Coder
    Join Date
    Feb 2012
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excuse me, becuse I don't have experience to work with .htaccess , but could you write me the htaccess ? And I want tosolve this problem with teams.php , because AC Milan.htm doesn't exist!
    Thank u and a happy new year!

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Just use this: RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9.\s]+)/?.html$ index.php?page=$1&name=$2.
    If you need the first one to also contain spaces and periods, add those too although that doesn't sound to be the case. It looks to me that you want to go to index.php though.

  • #5
    New Coder
    Join Date
    Feb 2012
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you, it works, you are an AMAZING man, but I still have a problem, I don't understand why is loading only the horizontal menu, but NOT loading the content of the file teams.php ...

  • #6
    New Coder
    Join Date
    Feb 2012
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ok

    It works, I had a little problem and I solved, thank u very much again!


  •  

    Posting Permissions

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