Jump to content

A Problem With .htaccess And A Dynamic Menu


milanello72

Recommended Posts

Hello again!

I have a dynamic menu like this:

***********

Teams

-juventus id_team=1

-ac milan id_team=2

-napoli id_team=3

..

..

**************

I have on anchor for every team

<a href="'.$page.'/'.$id_team.'/'.$name.'.html">......</a>

In home page when I access a team I will go in the next page:

calcioitalia2/teams/2/A.C. Milan.html

 

And in this page on the dynamic menu I have the next path:

calcioitalia/teams/2/teams/3/Napoli.html

*************************

So in the next page I have another "teams" and the old id_team (id=2 for AC Milan which was in the home page) and the "teams" and the current id_team (3 for Napoli) and the current name.

Obviously this page was not found on this server.

*********

How could i solve this problem?

In .htaccess i have:

RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/([a-zA-Z0-9.\s]+)/?.html$ index.php?page=$1&id_team=$2&name=$3

 

Must I change the .htaccess ??

Thank u very much!

Edited by milanello72
Link to comment
Share on other sites

I'm fairly certain it's because you need to add a beginning slash to the href.

 

Otherwise the server will pick-up the links from the current folder it believes it's in.

 

Apache manages the url business, PHP thinks it's in a folder and because you're missing the slash, PHP will just append the new url to the current url.

 

<a href="'.$page.'/'.$id_team.'/'.$name.'.html">......</a>

most likely should be

<a href="/'.$page.'/'.$id_team.'/'.$name.'.html">......</a>

 

Now, if you're not in the root of the domain, but a subfolder, you will need to append the subfolders name along with the starting slash.

Edited by iarp
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.