3

I would like when visitors type http://localhost/mywebsite/paris/ it calls http://localhost/mywebsite/page.php?city=paris

But when typed http://localhost/mywebsite/ it calls to http://localhost/mywebsite/index.php

RewriteEngine On
RewriteRule ([a-zA-Z-]*) /page.php?city=$1 [QSA,L]

I get the following error :

Not Found
The requested URL was not found on this server.
Amit Verma
  • 40,709
  • 21
  • 93
  • 115
  • Please share more details. Why should `http://localhost/mywebsite/` yield something else than the index if you haven't defined any rule for that? Your requirement is to match `http://localhost/mywebsite/paris/` – Nico Haase Oct 19 '20 at 06:59

1 Answers1

0
RewriteRule ^([a-zA-Z0-9]+)$ page.php?city=$1
RewriteRule ^([a-zA-Z0-9]+)/$ page.php?city=$1

  • 6
    Please don't post only code as answer, but also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes. – Mark Rotteveel Oct 19 '20 at 09:11