I want to rewrite my URLs on localhost. First parameter "p" is the page. all other parameters "param1" - "paramX" schould work when I need them. With only one parameter "p" it works every fine. But now I want editing a second parameter in the URL and just want to echo it first. This works too. But when I click on my menupoints, that only use parameter "p" as links, it don´t work right. I get no errors, but parameter "p" do not change, as it should, but "param1" changed and my menu doesn´t open any right site any more. I am a beginner in htaccess und hope you can help me. In the following I post some screenshots
htaccess File
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9a-zA-Z]+)$ index.php?p=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([0-9a-zA-Z]+)/([0-9a-zA-Z]+)$ index.php?p=$1¶m1=$2 [NC,L]
Parameter "P" for sites alone works well
Get the second parameter and index.php
Getting and echo the second parameter works too
But clicking on menupoint don´t work any more
Links with a-tag look like <a href = "projcet">Projekt</a>
or <a href = "acp">ACP</a>
As you can see, if I click on acp (link with href = "acp") it doesn´t changed the first parameter. It changed the second and the link doesn´t work any more.
Could you help me and could you tell me what I am doing wrong in my the htaccess file?
I tried to change the URL, but it doesn´t work. And I edited the htaccess file multiple times with try and error the last day and this is the best result I got. And the other possibilities from stayoverflow which showed up didn't help me.
Links with a-tag look like
<a href = "projcet">Projekt</a>
or<a href = "acp">ACP</a>
I think there's your problem. You're using directory-relative links in your menu but you seem to use the menu on every page. So if the user is at /project/test
, a link to acp
will link to /project/acp
. If you use an origin-relative link (in this case /acp
), it will correctly link to the URL you want. This has more to do with basic understanding of the workings of the HTML tag <a>
than with .htaccess.