Form outside of wordpress gives wordpress 404 on submit

I have a wordpress site, and a subdirectory on that server which has been excluded from wordpress. This is the line I’m using in the .htaccess file to exclude that directory:

RewriteCond %{REQUEST_URI}  !(app) [NC]

I have a form inside that directory. Whenever one of the fields contains a URL, I get a wordpress 404 on submit. If the field does not contain a URL, it submits normally. How can I solve this issue?

Read More

EDIT:

Here’s what I’ve tried:

  • Adding a prefix to the name of the form element
  • Using a random string of characters as the form element name
  • Encoding the value to base64 on form submission
  • Adding an .htaccess file to the subdirectory with a RewriteEngine Off command
  • Adding an “action” attribute to the form, both to itself and to another page, with relative and full URLs.

Here’s the full text of the wordpress .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_URI}  !(app) [NC]
RewriteRule ^other/(.*) /wp-includes/$1 [QSA,L]
RewriteRule ^file/(.*) /wp-content/uploads/$1 [QSA,L]
RewriteRule ^ext/(.*) /wp-content/plugins/$1 [QSA,L]
RewriteRule ^skin/main.css //index.php?style_wrapper=1 [QSA,L]
RewriteRule ^skin/(.*) /wp-content/themes/sirens/$1 [QSA,L]
RewriteRule ^ajax /wp-admin/admin-ajax.php [QSA,L]
RewriteRule ^wp-content/themes/sirens/screenshot.png|readme.html|license.txt|wp-content/debug.log|wp-includes/$ /nothing_404_404 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
<Files 403.shtml>
order allow,deny
allow from all
</Files>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</ifModule>

Here’s the form:

<form enctype="application/x-www-form-urlencoded" class="form-horizontal" method="post">
   <textarea id = "orders" name = "orders"></textarea>
   <input type="submit" value="Place order" class=" btn btn-blue">
</form>

In every case, the result is the same – it works without a URL in the field, but goes to a wordpress 404 page when there is a URL in the field.

Example:

  • Textarea contains “foo”. The form submits without issue.
  • Textarea contains “http://foo.com“. The form goes to a 404.

Related posts

Leave a Reply

2 comments

  1. Which .htaccess file are you adding your rule to? The default WordPress .htaccess, or within your subdirectory?

    Perhaps creating an .htaccess file within your subdirectory with the following will help:

    <IfModule mod_rewrite.c> 
    RewriteEngine off
    </IfModule>
    
  2. Try to use below code …

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /subdirectory-name/
    ....
    

    Other will be same

    It may help you..

    Regards,
    Nimesh P.