【发布时间】:2015-02-14 21:32:13
【问题描述】:
所以这是我总结的问题:
我有这个表单,(例如在页面 X 中)将数据提交到处理页面,其地址是由 Apache 的 RewriteAlias 映射的 URL。此表单的操作 URL 有一个会话哈希键作为 GET 查询,它需要通过该查询,并且随着每个用户的每次页面加载而变化。当您在处理页面中时,该会话哈希不会更改。通常它会通过,但在这种情况下它不会。
经过一段时间的调查,我认为发生这种情况的最可能原因是,当 Apache 处理包含所有重写条件的 .htaccess 文件并更改会话哈希键时,映射的 URL 必须以某种方式重定向到页面映射页面 X。当我使用页面 X 的原始未映射 URL 时发现了这一点(它将是 index.php?snowglobe={snowglobe} 而不是 /sg/{snowglobe}。我不知道是什么导致了映射 URL 以更改会话哈希,以及如何解决此问题。
包含会话哈希的 PHP sn-p
if(!isset($_GET['verify'])){ $_SESSION['temp_n'] = md5(microtime(true));} //this changes at every page except the processing page
.htaccess 文件
RewriteEngine On
RewriteRule ^profile/([A-Za-z0-9]+)/?$ index.php?profile=$1 [PT]
RewriteRule ^thread/([-_A-Za-z0-9]+)/?$ index.php?thread_view=$1 [PT]
RewriteRule ^profile_nuise/([-_A-Za-z0-9]+)/?$ index.php?query=$1 [PT]
RewriteRule ^profile_nuise/([-_A-Za-z0-9]+)/notifs/?$ index.php?query=$1¬ifs=all [PT]
RewriteRule ^profile_nuise/([-_A-Za-z0-9]+)/find/([A-Za-z_-]+)/?$ index.php?query=$1&find=$2 [PT]
RewriteRule ^profile_nuise/([-_A-Za-z0-9]+)/find/([A-Za-z_-]+)/?$ index.php?find=$2&query=$1 [PT]
RewriteRule ^profile_nuise/([-_A-Za-z0-9]+)/find/([A-Za-z_-]+)/submit index.php?find=$2&query=$1&direct=$2_submit [PT]
RewriteRule ^thread/([-_A-Za-z0-9]+)/comment/([a-z0-9]+)/?$ index.php?comment=$2&thread_view=$1 [PT]
RewriteRule ^thread/([-_A-Za-z0-9]+)/comment/([a-z0-9]+)/?$ index.php?thread_view=$1&comment=$2 [PT]
RewriteRule ^sg/([-_A-Za-z0-9]+)/?$ index.php?snowglobe=$1 [PT]
HTML 表单
echo "<div id='content' class='contentbox'>".$nx['31']."</div>";
echo "<form method='POST' action='".$main_dir."index.php?direct=new_post&verify=". $_SESSION['temp_n'] ."' id='post_k'>
<span id='input_save'></span>
<div class='extra_opts'><a href='add-poll' class='prompt' id='attach_poll_q'>".$nx[30]."</a></div><div id='main_new_post' class='contentbox'>";
echo "<div class='sect_1'><input type='text' maxlength='150' value='".$nx['17']."' class='flick largeform' name='tcha1' id='title_trigger'>
<textarea name='tcha2' class='flick largeform'>".$nx['18']."</textarea></div>";
//post as: formats
//title and content
echo "<div class='sect_2 button_row'>
";
//check for all snowglobes they can make a thread in, of course being able to post in your own profile snowglobe is always your right, and it'll be called "1"
echo "<input type='hidden' name='sg_".$sg_details['sg_url']."' value='on'>";
//as for the rest...
echo "
<input type='submit' value='".$nx['21']."'></div>";
echo "</div></form>";
【问题讨论】:
标签: php apache .htaccess session hash