douhan0562 2015-05-05 13:38
浏览 69

.htaccess文件不允许POST函数处理

I created an htaccess file that I saw on a tutorial. My main goal was to remove the .php at the end of the file names in my browser. This worked perfectly. However, I am running into some major issues since I have created this.

  1. Anything that has a method of POST will not process. It just reloads the current page, but does nothing.

  2. When I try to log in, it redirects me to my home page. Then when I go back to the signin page, it allows me to log in.

  3. My font-awesome images are no longer displaying.

Issue 1 and 2 are definitely the most important issues that need resolved. I've been stuck on this for days and cannot find anything that resolves this.

This is what I currently have that loads my pages fine, except for the issues I mentioned.

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example/$1 [R,L]

RewriteEngine On
RewriteBase /

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
RewriteRule ^er$ er.png [L]

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

This last part ^^ is one thing I tried to add to make the POST's work. It did nothing. It is positioned in the file just as I posted it in here.

I also tried using the following that someone created for me, but it doesn't even allow me to get on my site.

RewriteEngine On

# redirect to https
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.mysite/$1 [R,L]

# allow cross origin fonts
<FilesMatch ".(eot|ttf|otf|woff)">
    Header set Access-Control-Allow-Origin "*"
</FilesMatch>

# add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]

# allow php files to respond without extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# remove php extension if provided
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\\.php [L]

I have all of my POST methods directing like the following.

action="/index"
  • 写回答

1条回答 默认 最新

  • duanjiani6826 2015-05-05 14:02
    关注

    Try using absolute URL for e.g. http://localhost/yourwebsite/products in all <a href=""> and <form action="">.

    评论

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图