clusterBuddy clusterBuddy - 1 year ago 74
PHP Question

.htaccess rule error for redirecting from a homepage form submit

I have a top level domain that has a form in it, when I submit the form I get the error that it's no found (it's looking for it in the wrong place.)

the original locations of the index is here:

the php file that handles the form into the DB is here:

I am using this .htaccess rule to send my homepage to

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/tld/src/
RewriteRule ^(.*) /tld/src/$1 [L]

Obviously, the redirection is an error:
The requested URL /tld/src/lib/phpfile.php was not found on this server.
since the file exists in

My current and only settings except for the above are:

Options All -Indexes

<Files .htaccess>
deny from all

And that's it.

I am new to .htaccess apache rulesets and I have no idea how to fix this. Thank you.

Answer Source

You can tweak your exception condition:

RewriteEngine On
RewriteBase /tld/

RewriteCond %{REQUEST_URI} !/(src|lib)/ [NC]
RewriteRule ^(.*) src/$1 [L]

Above condition will skip any request that starts with /tld/lib/ or /tld/src/ thus allowing your form to be routed to correct php file in /tld/lib/ directory.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download