如何在mod_rewrite之后让我的联系表单工作?

时间:2011-01-21 21:46:26

标签: forms .htaccess mod-rewrite config

我使用CMS Made Simple构建了一个网站。我必须指出管理页面和联系表单之外的所有内容的主机URL。我能够成功地将mod_rewrite用于config.php并更改.htaccess,但现在我的联系表单不再有效(一个在页脚中,另一个在联系页面上)。这是我的.htaccess文件的样子:

  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]

我的POST异常可能无法正常工作吗?任何建议都是非常有必要的。该网站是:http://energyfa.ipower.com/ai/

谢谢, 科里

3 个答案:

答案 0 :(得分:1)

尝试从

更改.htaccess
# .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

# .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

它适合我们

答案 1 :(得分:0)

我发现表单上的操作设置为http://energyfa.ipower.com/ai/contact-us/。我认为会发生的是POST将转到该URL。您将点击您的第一个RewriteRule并再次重定向到联系表单,但由于它是浏览器重定向,它可能只是一个GET,因此您的POST内容永远不会进入您的脚本。

尝试将表单操作更改为http://accimpress.com/contact-us/,看看会发生什么。

答案 2 :(得分:0)

看起来CMS Made Simple在使用Pretty URL重定向您的URL时不支持其表单生成器模块,所以我现在的解决方案是使用发送此文件,如下所示:

http://accimpress.com/upload/

但感谢你的建议安德鲁!

相关问题