Forum Moderators: phranque
I am having an irritating problem with my URL rewrite in my .htacces file. I am trying to rewrite for example:
http://example.com/?sida=Fruit/Apples/Granny_Smith
to
Fruit/Apples/Granny_Smith
My .htaccess file looks as follows:
RewriteEngine On
RewriteRule ^([/a-zåäöA-ZÅÄÖ0-9_-]+)/?$ index.php?sida=$1 [L,QSA]
Here is my problem: if I for instance have a link like this
<a href="Fruit/Apples/Granny_Smith">Granny_Smith</a>
then it works fine the first time, the url says:
Fruit/Apples/Granny_Smith
But if I klick the link again the url now shows:
Fruit/Fruit/Apples/Granny_Smith
And if I click it again the url says:
Fruit/Fruit/Fruit/Apples/Granny_Smith
What am I doing wrong? Can somebody please write me a new .htacces that works, I would be ever so thankful.
[edited by: jdMorgan at 8:42 pm (utc) on Dec. 7, 2009]
[edit reason] example.com [/edit]
Also, your description is backwards, although not your rule: You are in fact rewriting a client request for the URLhttp://example.com/Fruit/Apples/Granny_Smith to the server filepath/index.php with a query string of "sida=Fruit/Apples/Granny_Smith".
The problem appears to be in the links on your pages or in your script. Make sure that the links on your pages for the URLs which are to be rewritten are in server-relative or canonical form. That is, use <a href="/Fruit/Apples/Granny_Smith"> or <a href="http://example.com/Fruit/Apples/Granny_Smith"> and not <a href="Fruit/Apples/Granny_Smith">
Jim