0

)

我正在创建一个动态事件创建应用程序,在为事件创建动态网页时遇到了问题。

我的 .htaccess 看起来像

RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f  
RewriteRule ^([^\.]+)$ $1.php [NC]
RewriteCond %{REQUEST_FILENAME} >""
RewriteRule ^([^\.]+)$ table.php?event=$1 [L]

我的 table.php 看起来像

$getEvent = explode("/",$_SERVER['REQUEST_URI']);
print_r($getEvent);
$conn = new mysqli($host, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}   
$result = $conn->query("SELECT * FROM event where link='$getEvent[4]'");
echo $getEvent[4];  

页面结构如下:

http://page.ex/~name.name/reg/

当我尝试进入

http://page.ex/~name.name/reg/joulupidu

尽管“joulupidu”在事件表中,但我得到 404。我不知道在哪里看,因为我以前没有做过很多关于这种东西的工作。

谢谢,WK!

4

1 回答 1

1

你的 .htaccess 应该像

RewriteEngine On
RewriteRule ^([^/.]+)/reg/([^/.]+)?$ reg/table.php?event=$2&%{QUERY_STRING}

你的 table.php 文件应该像

$getEvent = $_REQUEST['event'];
//print_r($getEvent);
$conn = new mysqli($host, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}   
$result = $conn->query("SELECT * FROM event where link='$getEvent'");
echo $getEvent;  
于 2016-04-28T05:38:11.927 回答