Forum Moderators: phranque
Here is my problem:
My htaccess file starts with a bunch of redirect 301 commands, and ends with a set of url rewriting rules.
I have been using mod_rewrite to rewrite my dynamic URL into a static looking URL. For instance, the url /club/crobar/ is actually rewritten by apache into guide.php?category=club&name=crobar
Now, I need to redirect an old URL to the new location of the page (namely: /club/studio_mezmor/ ) because the name of the place has changed.
So I added to my htaccess: redirect 301 /club/crobar/ [......]
The problem is when I look at my logs, I see that the agent has followed the redirection but has also applied the rewriting rule to the redirected URL, which gives:
[......]
Is there a command similar to [L] that could be added to a redirect 301 in order to stop the server looking for other rules or command?
Thank you for your assistance with this.
Lothaire
Each Apache module in turn reads your .htaccess file in the order specified by the server configuration, and applies only those directives that it understands. Therefore, only directives for the same module are executed in the order that you write them in your .htaccess file.
To clarify, the likely cause is that your internal rewrite (mod_rewrite) is being applied first, and the the external redirect (mod_alias) is invoked, thus exposing your internal script URL to the client.
So, I'd recommend that you re-code your redirect using mod_rewrite, and place it in the first section with your other redirects -- above the internal rewrites. That will likely make your problem go away.
Jim