0

)

I am creating a dynamic event creation application and I have run into a problem when creating dynamic webpages for events.

My .htaccess looks like

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

And my table.php looks like

$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];  

The page structure is as following :

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

And when I try to entry

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

I get 404 although "joulupidu" is in event table. I have no idea where to look, because I haven't done much work with this kind of stuff before.

Thanks, WK!

1 Answer 1

1

Your .htaccess should be like

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

And your table.php file shoul be like

$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;  
Sign up to request clarification or add additional context in comments.

9 Comments

Hey, thanks for the input. It nows seems to point to the right URL but it still says 404 when I'm trying to go to my GetEvent url
Let's say I have a link="test" in my event table, so when I go to page.ex/~name.name/reg/test , it says 404
Still 404, manually typing reg/table.php?event=test works, so it must be htaccess
Check the htaccess again, and if not working than give me the path where your table.php file
I try to access the above link but manually typing the link also throws 404
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.