1

I have been having an issue with our contact forms on our GoDaddy hosted website. They have told me they have no recommendation for a fix. It seems that when we implement .htaccess rewriting to remove .php extentions, this breaks our contact forms and they wont send mail when the form is submitted. This is the htaccess code that we have that breaks the contact forms:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} mypureform\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mypureform.com/$1 [R,L]

# hide .php extension

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

Is there another way we can rewrite the extensions that won't break the contact forms?

Edit I have figured out that it's not working because when it tries to call on the action file ie "formhandler.php" the url gets rewritten to exclude the .php so it can't find the right file. Is there a way to exclude certain directories from having their urls rewritten?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Samson
  • 21
  • 6
  • How do you send your mail, is it through AJAX or page reload, cause this has nothing to do with .htaccess or partly has to do with it. – Shasha Nov 22 '18 at 21:06
  • I believe it's AJAX. When the user submits the form, it loads a php form handler and redirects to the thank you page. – Samson Nov 22 '18 at 21:10
  • Don’t do the “hide .php extension” redirect, you’re causing double requests for everything. Instead, fix your actual URLs in your links and forms to be “.php-less”. – deceze Dec 31 '18 at 10:32

1 Answers1

1

I managed to fix everything! Since the htaccess file was rewriting every single document and removing the .php at the end, the form actions weren't being called upon properly. To fix this I simply added a new .htaccess file in the actions folder, and added:

RewriteEngine Off

Hopefully this helps anyone having a similar issue!

Samson
  • 21
  • 6