Forum Moderators: phranque

Message Too Old, No Replies

Post and Get issues with functionality

         

CainIV

5:42 am on Jan 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi guys.

I recently wrote this code for a website I work for which works great except for one issue:

Options FollowSymlinks

RewriteEngine On
RewriteCond %{HTTP_HOST} ^somesite\.us
RewriteCond %{REQUEST_URI} ^/?$ [OR]
RewriteCond %{SERVER_PORT}!443
RewriteRule (.*) [somesite.us...] [R=301,L]

"RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ [somesite.us...] [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ [somesite.us...] [R=301,L]

The administrator of the website and hosting has stated:

Your problem is in your chain, you will redirect a POST request to an index.php page to the index.php page via a GET request, thus breaking the functionality"

Any help regarding this issue as quite frankly I am not entirely suer what he means.

Thanks and Happy New Years Guys!

jdMorgan

2:48 pm on Jan 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That might be a problem, but only if you actually POST to "/index.php" or post to the "wrong" form of your domain.

If you POST only to "/" in your canonical domain, then there is no problem.

You can disable the redirect for POSTs to index.php by making this change to your third rule:


RewriteCond %{THE_REQUEST} !^POST\ /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ http://www.example.com/$1 [R=301,L]

You may need to incorporate a similar change to the first rule and/or move that first rule below the other two, depending on what you're trying to accomplish overall.

BTW, your admin guy is very good to spot such a problem... :)

Jim

CainIV

5:35 pm on Jan 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh tell me about it, he thinks so too. His mail nick 'Your Expert'

Thanks for the code and explanation Jim.