Forum Moderators: phranque
One of the old addresses was:
[test.com...]
and the new page is at
[test.com...]
I'm using mod_rewrite on Apache 2, and I've included a line in it:
Redirect 301 /index.php\?option=com_wrapper&view=wrapper&Itemid=54 /email-list.htm
It just resolves to the main page of the site...
There is another rule that might be causing problems, but I need it for friendly URLs to work:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Unfortunately, the new CMS also uses the index.php format, but none of the same parameters are passed. Can I just parse those parameters strings and point to the new page for the three I really need? Why do I need these ones? They are marked as favourites and on the desktop of about 800+ PCs...and we don't have the resources to change all of them right away...
Why not make it with mod_rewrite?
RewriteCond %{QUERY_STRING} option=com_wrapper&view=wrapper&Itemid=54 [NC]
RewriteRule ^index\.php$ http://www.example.com/email-list.html [R=301,L]
for the following rules:
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{QUERY_STRING} option=com_wrapper&view=wrapper&Itemid=54 [NC]
RewriteRule ^index\.php$ [test.wip...] [R=301,L]
I've moved the query string condition and rule both before and after the request filename. Can I put the Query string one first and then prevent other RewriteRules from happening?
As a general rule, all external redirects should go first, in order from most-specific patterns and conditions to least-specific, followed by all internal rewrite, again from most- to least- specific.
Be aware that your currently-first rule will rewrite any request to index.php if the request does not resolve to an existing file or directory. The currently-second rule does an external redirect to test.wip/blog.htm.
So whether this code loops or not hinges on which of the target URLs actually exists as a file, and on whether the redirect is to a domain that is also handled by this same .htaccess code. Not knowing which or whether those possibilities exist, I can't tell why the code is looping.
You can always explicitly prevent a rule from being re-invoked (and looping) by excluding the target URL in a RewriteCond. For example, if index.php in the first rule does not actually exist, then you'd need to add
RewriteCond %{THE_REQUEST} !^/index\.php$
Jim