It is possible to method to place relative Web addresses in php code for example
/forums/(forumID)/ into tags while establishing my website? When I'm looking to get which forumID the present page is, to have it using a
$_GET request without needing a template system like Smarty, CakePHP etc or Apache rewrite module? Or perhaps is it an enormous headache? Among the finest to have the ability to 't be certain to one web server type (Apache).
Clean web addresses are simple enough to complete, but when the webpages are greatly different, you can get some problems.
You will need to edit your .htaccess file and add something such as this
RewriteEngine On RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1 #This will process http://example.com/forum as http://example.com/index.php?page=forum RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1 #This includes the trailing slash RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ index.php?page=$1&id=$2 #This will process http://example.com/forum/512 as http://example.com/index.php?page=forum&id=512
This is an excellent source to learn more http://www.desiquintans.com/cleanurls
... transported on from OP comments.
These frameworks browse the request again within their particular languages to permit the framework to path to specific remotes, however they still require the webserver to become setup to transmit the request towards the framework to begin with.
- Client demands http://example.com/forums/123
- After DNS research, request hits server at 127...1:80
- Webserver (eg Apache) listens for port 80 and accepts request
- Apache routes request to server-side script
This is actually the journey because the web server sees it. It must browse the request before it even hits the server-side scripting language (PHP/Python/Ruby etc).
The server-side languages may then re-browse the URL when the webserver has hit the leading controller as they wish.
The primary good reasons to have clean web addresses from an architecture perspective:
- They aren't associated with any programming language. For those who have
.phpor other extensions, you'd have to setup your server to simply accept
.phpextensions for other languages should you change to ASP.internet.
- They're are simple to route in almost any language or server setup. All modern servers I understand of have modules to route web addresses.
Observe that to utilize a programming language to route the web addresses, you've still got to setup your server to direct everything to some bootstrap file. Honestly, you aren't making your way around server designs of some type regardless of what.
Conclusion: your logic for wanting any project setup by doing this won't work without having done some server setup.