Forum Moderators: phranque
I have a folder called brands with the following htaccess file:
Options FollowSymLinks
RewriteEngine On
RewriteRule ^(product)-([^-]+)\.html$ ../product.php?product_type=machine&id=$2 [L]
RewriteRule ^(.*)-([^-]+)\.html$ ../category.php?link_from=$1&page=$2 [L]
When I click on <a href="brands/name-1.html">name</a>
I get that link_from=name name.
Does anyone know why that happens?
In my other sites I used the exact same method and it worked just fine.
Thanks.
[edited by: jdMorgan at 12:19 pm (utc) on Sep. 2, 2009]
[edit reason] Tidied up. [/edit]
This is a very strange result. I don't see anything in the code you posted that would certainly cause this problem. I do note, however, that you're using "../" as a destination path. I'd recommend that you provide a fully-rooted path instead, e.g. "/category.php?link_from=$1&page=$2" instead of "../category.php?link_from=$1&page=$2"
Also, look for other rules in this .htaccess file and in the root directory's .htaccess file which may rewrite this rule's input path before this rule executes, or which may re-rewrite this rule's output path after this rule executes... Remember that mod_rewrite in a .htaccess context is effectively recursive, and execution of mod_rewrite will be re-started every time any rule has been invoked. This can lead to "infinite loops," or --as in this case-- unexpected operation.
Jim