Scott D
Scott D

Reputation: 21

How can I stop these .htaccess rules clearing my $_POST variables?

Thanks for the help on here with my query on here the other day with regard to some htaccess problems I've been having - it sent me in the right direction to be able to work out what's causing the problem just I can't work out how to fix it.

The htaccess file for my site is...

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example.org
RewriteCond %{HTTP_HOST} ^(.+).example.org/^(.+)
RewriteRule ^([^/]*)$ http://example.org [P,L]

ErrorDocument 404 /index.php

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php [L]

</IfModule>

The first bit allows me to have virtual subdomains for my clients - they all include the same files from my main domain but a different layout is used and different data fetched from the db by my scripts depending on the subdomain. However it seems this code is destroying any $_POST variables... as when I submit a form on the main domain the script picks up the variables whereas with any of the subdomains using the exact same form and exact same script the $_POST variables are blank.

How can I fix that section of code, or add another bit, to allow $_POST variables to be passed as well? Get seems to work on the site using the last section as /logout/?logmeout is recognised it's just Post that is lost.

Upvotes: 0

Views: 433

Answers (1)

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324840

If you already have the wildcard vhosts set up that you need to allow such subdomain use, you shouldn't need to redirect to the main domain. Just have your PHP scripts check $_SERVER['HTTP_HOST'] to see what subdomain is being accessed.

Upvotes: 2

Related Questions