Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-01-2013, 05:19 PM   PM User | #1
milanello72
New Coder

 
Join Date: Feb 2012
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
milanello72 is an unknown quantity at this point
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!
milanello72 is offline   Reply With Quote
Old 01-01-2013, 05:41 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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 /.
Fou-Lu is offline   Reply With Quote
Old 01-01-2013, 05:47 PM   PM User | #3
milanello72
New Coder

 
Join Date: Feb 2012
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
milanello72 is an unknown quantity at this point
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!
milanello72 is offline   Reply With Quote
Old 01-01-2013, 05:50 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Old 01-01-2013, 06:16 PM   PM User | #5
milanello72
New Coder

 
Join Date: Feb 2012
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
milanello72 is an unknown quantity at this point
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 ...
milanello72 is offline   Reply With Quote
Old 01-01-2013, 07:09 PM   PM User | #6
milanello72
New Coder

 
Join Date: Feb 2012
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
milanello72 is an unknown quantity at this point
ok

It works, I had a little problem and I solved, thank u very much again!
milanello72 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:12 PM.


Advertisement
Log in to turn off these ads.