SOLVED: ReWrite URL Extensions Without Breaking Contact Forms .htaccess












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?










share|improve this question
























  • 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 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 at 21:10
















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?










share|improve this question
























  • 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 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 at 21:10














1












1








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?










share|improve this question















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?







php forms .htaccess






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 22:29

























asked Nov 22 at 20:48









Samson

165




165












  • 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 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 at 21:10


















  • 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 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 at 21:10
















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 at 21:06




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 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 at 21:10




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 at 21:10












1 Answer
1






active

oldest

votes


















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!






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437820%2fsolved-rewrite-url-extensions-without-breaking-contact-forms-htaccess%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    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!






    share|improve this answer


























      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!






      share|improve this answer
























        1












        1








        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!






        share|improve this answer












        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!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 at 22:29









        Samson

        165




        165






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437820%2fsolved-rewrite-url-extensions-without-breaking-contact-forms-htaccess%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks