开发者

How do I get my contact form to work after mod_rewrite?

开发者 https://www.devze.com 2023-02-05 20:52 出处:网络
开发者_如何学GoI\'ve built a site using CMS Made Simple. I have to point the host URL for everything EXCEPT the admin page and the contact forms. I was able to successfully do this with mod_rewrite to
开发者_如何学Go

I've built a site using CMS Made Simple. I have to point the host URL for everything EXCEPT the admin page and the contact forms. I was able to successfully do this with mod_rewrite to the config.php and changing up the .htaccess, but now my contact forms are no longer working (one in the footer and one on the contact page). Here is what my .htaccess file looks like:

  Options +FollowSymLinks
  RewriteEngine on
  RewriteBase /

  RewriteCond %{HTTP_HOST} ^energyfa.ipower.com$ [NC]
  RewriteCond %{REQUEST_URI} !^/ai/admin/
  RewriteRule ^(.*)$ http://accimpress.com/$1 [R=301,L] 

  # 301 Redirect all requests that don't contain a dot or trailing slash to
  # include a trailing slash
  # except for form POSTS
  RewriteCond %{REQUEST_URI} !/$
  RewriteCond %{REQUEST_URI} !\.
  RewriteCond %{REQUEST_METHOD} !^POST$
  RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

  # Rewrites urls in the form of /parent/child/
  # but only rewrites if the requested URL is not a file or directory
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.+)$ index.php?page=$1 [QSA]

Is there a reason my POST exception might not be working? Any suggestions will be much obliged. The website is: http://energyfa.ipower.com/ai/

Thanks, Cory


try changing your .htaccess from

# .htaccess for CMS made simple
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [NE,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
# EOF

to

# .htaccess for CMS made simple
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !$   <--- to put the "/"  ---->
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI} [NE,R=301,L]   <--- to put the "/" after } ---->
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
# EOF

it work for us


I see that the action on your form is set to http://energyfa.ipower.com/ai/contact-us/. What I believe will happen is that the POST will go to that URL. You will hit your first RewriteRule and get redirected to the contact form again, but since it's a browser redirect, it will probably just be a GET, so your POST content never makes it to your script.

Try changing the form action to http://accimpress.com/contact-us/ and see what happens.


It looks like CMS Made Simple doesn't support their Form Builder module once you've redirected your URL with Pretty URLs, so my solution for now was using Send This File, like so:

http://accimpress.com/upload/

But thanks for your suggestions Andrew!

0

精彩评论

暂无评论...
验证码 换一张
取 消