0

Here is my htaccess

Options -Indexes
<IfModule dir_module>
DirectoryIndex in.php
</IfModule>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule \.(css|jpe?g|gif|png|js|css|htm|html|mp3|wav|ico)$ - [L]
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


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

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^some/(.*)/(.*)/$ test.php?z=$1&n=$2 [NC,L]
RewriteRule ^some/(.*)/(.*)$ test.php?z=$1&n=$2 [NC,L]
RewriteRule ^some/(.*)/$ test.php?z=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !.*test.php$ [NC]
RewriteRule ^([^\.]+)$ $1.php [NC,L]

None of the $_POST with relative paths are working after implementing mod_rewrite.

Note :I have already set < base href="http://example.com/"/> and RewriteBase / as mentioned above

I have gone through other questions at SO but no luck!

Thanks for your advise!

I'm sorry.. Not working in the sense, POST variables are probably getting lost during htaccess redirects ???

Yesh
  • 63
  • 9
  • Please clarify 'Not working'. That's possibly the least helpful you could have been. – Philip Whitehouse Feb 10 '13 at 17:22
  • I'm sorry.. Not working in the sense, POST variables are probably getting lost during htaccess redirects ??? – Yesh Feb 10 '13 at 17:24
  • Please see this post regarding POST variables and redirects: http://stackoverflow.com/questions/13628831/apache-301-redirect-and-preserving-post-data – David Ravetti Feb 10 '13 at 18:23

1 Answers1

1

I would validate the code you are using to build your form actions. I agree with the above commentors that you are losing your POST variables because of the redirect.

Why might this be happening?

First off, that rewrite rule to redirect from non-www to www should only happen the first time someone visits your website without the www's. You should program accordingly.

Ie - someone types in 'example.com' - your rewrite will take them to 'www.example.com'

From then on, if you must refer to your full domain in a form, use the entire WWW version.

<form action="http://www.example.com/processForm.php" method="POST">

Alternatively, you could stop using the full domain.

A common place I've seen this happen is when programmers use plugins that define a configuration object. Perhaps that configuration object is pointing to the non www version by accident. Imagine this code:

$config = array('domain'=>'example.com', 'othersettings'=>'more here');

Forms are sometimes created doing this:

<form action="<?php echo $config['domain'] ?>/processForm.php" method="POST">

See, that would get translated into the non-www version, losing your POST values.

Good luck!

Aaron Saray
  • 1,178
  • 6
  • 19
  • Aaron - I must simply say Excellent! I never thought this could be the issue. Initially I did not understand what you were saying here later I realized it from the developer tools :) Now I added www. to my base link and things are working like charm. `< base href="http://www.example.com/"/>` Thanks Aaron ! – Yesh Feb 11 '13 at 05:59