DEV Community

URL Routing for Simple Websites

Cedric W on April 12, 2019

For a simple website (not Vue, React, non-framework), can you set up a routing system for url's or is it better to store url's within a simple list...
Collapse
 
horus_sky profile image
Cedric W

thanks, your example is what I have already. The regex is slightly different

#change file extensions
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteCond %{REQUEST_FILENAME}\.htm -f
RewriteRule ^(.*)$ $1.htm

The project I'm working on have about 12 pages but 8 of them are basically the same. Thats why I was considering routing. But I'm not using a DB, the site is really simple. Just wanted to know if the htaccess way the most efficient, or could I create a route config file.

 
horus_sky profile image
Cedric W

had some brief experience with Codeigniter back in 2010, but I didn't know a quarter of what I know now. I might give it a look over. Thanks!

Collapse
 
npips1991 profile image
Narendra Patel

Not Working