pag
to go into a specific folder and look for a <pagname>.html
file with the page content to be loaded for each page. The result is a url which looks like this:
http://<domain.tld>/pagina.php?pag=pagnameThis kind of URL is not very SEO-friendly, so I decided to use the mod_rewrite module, which is pretty much the standard on Apache installations, to turn them into something more human- and search-engine-readable.
New URLs would be in the form of
http://<domain.tld>/p/pagnameIn order to do this I played around with the .htaccess file in the main directory and added the following lines:
RewriteEngine on RewriteBase / RewriteRule ^p/([a-z0-9]+)$ pagina.php?pag=$1 [NC,L]The first two lines simply initialize the mod_rewrite extension since it was not previously used and tell it to calculate the addresses relative to the web root folder. The third line is the real rewriting rule, which tells to internally translate any url in the new form into the one using the GET variable; this will happen transparently, without the real address being shown to the users browsing.
To be noted is the fact that there is a debate online about whether is better to terminate URLs with a slash or not, with no clear winner. The most used strategy on CMSs is to add
.html
to those addresses, making dynamic pages actually look like they were static files. I might do some A/B testing in the future, but SEO is no exact science, so don't expect clear results.
No comments:
Post a Comment