我正在为我的婚礼网站设置重定向,因此http://www.mydomain.com/rsvp.php/q/something
重定向到http://www.mydomain.com/rsvp.php?q=something
,但仅在服务器端(即客户端仍在其地址栏中看到rsvp.php/q/something
)。Apache重定向工作不正常
现在,我在我的Apache配置下面这个网站:
<VirtualHost *>
ServerAdmin [email protected]
ServerName www.mydomain.com
DocumentRoot /var/www/www.mydomain.com
Options -Indexes +FollowSymLinks
RewriteEngine on
RewriteRule ^/rsvp.php/q/(.*) /rsvp.php?q=$1
</VirtualHost>
现在,我也有一个在PHP文件的顶部(元重定向事件,用户没有按”在q查询变量中没有任何内容):
<?php
$userHash = $_GET['q'];
?>
<!doctype html>
<html>
<head>
<title>Wedding - RSVP Page</title>
<?php
// If we don't have a user hash, then let's redirect to the main
// page.
if (!$userHash) {
echo '<meta http-equiv="refresh" content="0; url=http://www.mydomain.com/">';
}
?>
此外,这似乎工作正常,只有一个例外。我正在使用一个表单来输入他们的RSVP数据。提交时,它会调用脚本submit-form.php
。当访问地址http://www.mydomain.com/getID.php时,它会重定向到index.html,这不是我想要的。
如果我删除RewriteRule
,它会按预期工作,但我没有得到一个不错的网址(我不得不使用q=something
而不是q/something
)。我对mod_rewrite并不擅长,所以我想知道是否有人可以给我一些帮助,让我知道我做错了什么。
谢谢!
对不起......我没有正确阅读帖子。这很好,谢谢。 – jwir3 2012-04-22 21:11:35