Directories: eventfinder is project folder
- Localhost
-- project1
-- project2
-- eventfinder
--- .htaccess
User comes to the page http://localhost/eventfinder/ and types 'randomevent123' after /eventfinder/
then php query happens with ?event=randomevent123
$event = $_GET['event'];
$stmt = $conn->prepare("SELECT * FROM events WHERE name = :name");
$stmt->bindParam(":name", $event);
$stmt->execute();
and returns data from database
I am trying to rewrite my url but I don't understand what is the problem...
http://localhost/eventfinder/index.php?event=randomevent123
to
http://localhost/eventfinder/randomevent123
With .htaccess
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?event=$1 [L]
But query won't work.
RewriteRule ^eventfinder/([^/]+)/?$ /index.php?event=$1 [L]you're not taking into account/eventfinder/at the moment.RewriteEngine On RewriteRule ^eventfinder/([^/]*)$ /eventfinder/index.php?event=$1 [L]/eventfinder/in the resulting path as well :\ ... unless/eventfinderis an actual directory and that's where the .htaccess file resides?