Question

Because of strange cross domain AJAX problems, causing AJAX requests to fail when not using www.(the PHP handler communicating with the request is given in a relative path, so it can't be an address issue or something - that's what this question is about though), I have forced www. using .htaccess :

#enable rewrite engine and set options
Options +FollowSymLinks
RewriteEngine on

#only www.
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]

This works great. However, I want to allow other webmasters to post one of my forms on their website, using my form URL in their form's action attribute. This always worked, however after my .htaccess change the forms are only submitted when the webmaster adds www. to the action value. Without www. the form will not get submitted.

How should I change my .htaccess file to make sure that these forms are also submitted without www.?

Was it helpful?

Solution

You could use

RewriteCond %{REQUEST_METHOD} ^GET$

which will rewrite only GET requests, leaving POST requests as they are.

OTHER TIPS

Most browsers don't forward POSTed data when 301 Redirected... So you will see those requests as a GET of your action url instead.

This behaviour is technically non-compliant but seems to be the commonly accepted approach.

(c.f. http://www.lassosoft.com/Documentation/TotW/index.lasso?9083, http://www.nkuttler.de/2008/11/09/mailman-and-301-redirects/.)

Maybe try 307 Temporary Redirects for your forms? 307 specifically instructs the browser to re-POST the data. http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top