In order for us to handle all requests to a directory, we'll create a .htaccess
file in the working directory.
1. Create a file called
.htaccess
in the working directory.2. Add the following code to the file:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?request=$1 [QSA,L] </IfModule>
3. Open the file
index.php
in the working directory.4. Change the code inside of
index.php
to match the following:<?php echo $_GET['request']; ?>
5. Open your browser, go to
http://localhost/verge/test/abc
, and go tohttp://localhost/verge/test/123
. Notice that the page will respond back to you with the same value that you entered at the end of the root URL.