I’m at few hours looking a various tuts on mod_rewriting, but anything I try myself never seems to work. What I’m hoping for is that I can give you guys the URL model, and get a working Rule and a breakdown of that Rule in return (I’m reasonably familiar with regex). That way I can adapt to future requirements also.
The structure is:
domain.com/contents/page.php?id=123&u=page-slug
What I want is for the user to type:
domain.com/page-slug
and be successfully redirected to the page in question.
From what I have read, this shouldn’t affect PHP GET’s – is this correct? Even if the id isn’t actually in the address bar (obv. question, but I’m completely new to this)? It’s surprising what tutorials leave out…
Thanks in advance!
If the ID is necesary then it will need to be present in the pretty url i.e. something like
domain.com/page-slug/page-id.To rewrite this to
page.phpadd the following to your .htaccess in the root directory ofdomain.comas belowIf you want to learn more see this list of .htaccess and mod_rewrite resources on the web