Php htaccess重写和提交表单不协同工作
经过几次研究后,我放弃了,在这里发帖子,如果有人能告诉我一些事情,那就太好了,谢谢 当我使用all works时,ajax会向file.php发送一个post并显示它,但当我使用由htaccess重写的url post表单时,它就不起作用了 链接: 原件: 使用htaccess重写: 数据库条目:2012/08/14/My first post 要添加html agter页面,我添加了Php htaccess重写和提交表单不协同工作,php,jquery,ajax,.htaccess,rewrite,Php,Jquery,Ajax,.htaccess,Rewrite,经过几次研究后,我放弃了,在这里发帖子,如果有人能告诉我一些事情,那就太好了,谢谢 当我使用all works时,ajax会向file.php发送一个post并显示它,但当我使用由htaccess重写的url post表单时,它就不起作用了 链接: 原件: 使用htaccess重写: 数据库条目:2012/08/14/My first post 要添加html agter页面,我添加了 $url=$url.'.html'; $url= $_GET["url"]; 我的ajax文件位于file
$url=$url.'.html';
$url= $_GET["url"];
我的ajax文件位于file.php中
<SCRIPT language="JavaScript">
$(function() {
$(".comment_button").click(function()
{
var element = $(this);
var note = $("#note").val();
var dataString = 'note='+note;
if(note=='')
{
$('#flash').fadeIn("fast");
}
else
{
$.ajax({
type: "POST",
url: "file_post.php",
data: dataString,
cache: false,
success: function(html){
$('body').load('/<? echo $url ?>.html');
}
});
}
return false;
});
});
</script>
<form name="comment" method="post" action>
<button class="comment_button" type="submit"><span>Отправить</span></button>
<textarea name="note" id="note"></textarea>
</form>
我的htacces
Options +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteBase /
<Files inc/config.php>
deny from all
</Files>
RewriteRule ^([a-zA-Z0-9-/]+).html$ file.php?url=$1 [QSA,L]
RewriteRule ^([a-zA-Z0-9-/]+).html/$ file.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options+FollowSymLinks
选项-索引
重新启动发动机
重写基/
全盘否定
重写规则^([a-zA-Z0-9-/]+).html$file.php?url=$1[QSA,L]
重写规则^([a-zA-Z0-9-/]+).html/$file.php?url=$1[QSA,L]
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}\.php-f
重写规则^(.*)$$1.php
重写页面上的$\u服务器['REQUEST\u URI']给了我一个空输入,这正常吗 尝试将两条规则更改为:
RewriteRule ^([a-zA-Z0-9-/]+).html$ file.php?url=$1.html [QSA,L]
RewriteRule ^([a-zA-Z0-9-/]+).html/$ file.php?url=$1.html [QSA,L]
.html
被剥离,因此您的file.php脚本被调用如下:
http://site.com/file.php?url=2012/08/15/My-html-page
而不是
http://site.com/file.php?url=2012/08/15/My-html-page.html
我不知道是什么错误,有斜杠或数字和htaccess 但我找到了一个解决办法
RewriteRule ^read/([A-Za-z0-9\-_]+]*)$ file.php?url=$1 [L]
如果没有html或php请检查此stackoverflow问题:问题可能出在RewriteCond%{REQUEST_FILENAME}-d RewriteCond%{REQUEST_FILENAME}\.php-f RewriteRule^(.*)$$1.phpi使用它从文件中删除php对不起,我忘了提到我添加了一个带有html$url=$url.html的php变量;我对帖子做了一些修改
RewriteRule ^read/([A-Za-z0-9\-_]+]*)$ file.php?url=$1 [L]