Forums

Mod Rewrite Kills form submission

markccs 03 May, 2012
My forms on apache do not post when the mod rewrite is enabled. This is a problem because I'm trying to prevent duplicate content, but want the www included. I've seen a post here where the person went the opposite way (without a wwww), but I don't want that.

I'm using this, which works fine, but prevents a form submission from going through. The error message is: You are not allowed to access this URL directly, POST array is empty

RewriteBase /
#RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC]
#RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
GreyHead 04 May, 2012
Hi markccs,

Technically I think that the 301 redirect doesn't preserve the POST variables - it you want to submit forms then you can't do this. There's a possible answer here

Bob
markccs 07 May, 2012
That may work, but I couldn't get it too.

I don't really understand the re-write rules that well. I've managed to fair well enough with copying and pasting what I need.


This is what is recommended:

# Forces a trailing slash to be added

RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]



This is what I have:
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]


How would I fit these together?

Thanks!
GreyHead 13 May, 2012
Hi markccs,

Sorry but this is beyond my competence :-(

Bob
This topic is locked and no more replies can be posted.