Forum Moderators: phranque
mydomain.com/catalog/test.php?something
=(301)=> mydomain.com/en/test.php
=(301)=> mydomain.com/en/test.php
=(301)=> ...
My .htaccess file:
Options -Indexes
Options FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^catalog/test.php$ en/test.php?[R=301,L]
RewriteRule ^(frŠenŠes)/(.*)$ /catalog/$2?language=$1 [QSA,L]
Looks like the first rewriterule is executed after the second rewrite rule. I have tried removing both "lastrule" [L] but that didn't help. How can I make my .htaccess only run once?
Without knowing what you are trying to redirect from and too with each of those rules, and the cases for when each should run, or not run, I can't offer any sample code.
# Externally redirect from /catalog/test.php to /en/test.php, removing
# the query string, but only if the request is a direct client request
# and not a result of the following internal rewrite
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /catalog/test\.php\?
RewriteRule ^catalog/test\.php$ http://www.example.com/en/test.php? [R=301,L]
#
# Internally rewrite /<language>/<anything>
# to catalog/<anything>?language=<language>,
# retaining any pre-existing query string
RewriteRule ^(frŠenŠes)/(.*)$ /catalog/$2?language=$1 [QSA,L]
I removed your QUERY_STRING RewriteCond, since it didn't do anything other than burn CPU cycles, and I couldn't discern what it might have been intended to do.
Replace the broken pipe "Š" characters with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Jim