jdMorgan

msg:3853488 | 10:44 pm on Feb 19, 2009 (gmt 0) |
Check the initial client request to stop the loop:
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php[^\ ]*\ HTTP/ RewriteRule ^index\.php$ http://www.example.com/index.ht[b]ml?[/b] [R=301,L]
This prevents redirecting index.php to index.html if the request for index.php is the result of the action of your internal rewrite rule; Only direct client requests for index.php will get redirected to index.html. Note that I recommend dumping the "index.html" if possible, and simply redirecting to "www.example.com/". Try this after testing the rule as written above. This redirect rule should go before your general domain canonicalization redirect (if you have one), and all such external redirect rules should be placed before all of your internal rewrite rules. Jim [edit] Corrected code to fix problem reported below. [/edit] [edited by: jdMorgan at 4:19 pm (utc) on Feb. 24, 2009]
|
Scally_Ally

msg:3856576 | 12:57 pm on Feb 24, 2009 (gmt 0) |
Thanks alot for you help bill - I still have so much stuff to learn with htaccess.. this worked well in stopping the infinite loop, the only problem that i have now is that the querystring then gets attached to the index.html page. I have done alot of research but cannot find how to stop the querystring getting passed across. The redirect at the moment goes http://www.example.com/index.php?cat=sdasasas goes to http://www.example.com/index.html?cat=sdasasas I just want it to go to http://www.example.com/index.html without the query string. Many thanks again. Ally
|
jdMorgan

msg:3856730 | 4:21 pm on Feb 24, 2009 (gmt 0) |
Yeah, I always forget to tell the rule to remove the query. Hopefully no-one else has copied the original code. :( See the corrections in my post above. Jim
|
g1smd

msg:3856952 | 8:33 pm on Feb 24, 2009 (gmt 0) |
I would usually redirect to a URL that does not include the index file filename in the target, the target URL then simply ending with a trailing slash.
|
Scally_Ally

msg:3858112 | 9:56 am on Feb 26, 2009 (gmt 0) |
Thanks a lot for you help Jim, works perfectly now. (who would have thought a question mark could do so much..) I have taken your advice g1smd - my rewrite now looks like RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php[^\ ]*\ HTTP/ RewriteRule ^index\.php$ http://www.example.com/? [R=301,NC,L]
So it doesnt incorporate the index.html Thanks again Ally
|
g1smd

msg:3858739 | 11:11 pm on Feb 26, 2009 (gmt 0) |
That will work fine as long as the right index file filename is mentioned in the DirectoryIndex directive. By the way, that code directly above is for a redirect, not a rewrite.
|
|