I have built myself a small MVC with following htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?controller=$1 [QSA,L]
when I now click on a link http://example.com/mycontroller/
I get to the controller mycontroller
.. everything works fine here.
but inside http://example.com/mycontroller/
I have further links i.e. http://example.com/mycontroller/edit/1
which lead me to http://example.com/mycontroller/mycontroller/edit/1
(?)
how can that be? how can I fix this?
How do the links in your HTML look like?
<a href="/mycontroller/edit/1" ...
or <a href="mycontroller/edit/1" ...
?
The latter is relative to the current path, and when you're already at /mycontroller/
, it will expand to /mycontroller/mycontroller/edit/1
To solve this you need to make your links server-relative (i.e. begin with a /
)