.htaccess custom url with php
# June 25, 2009 at 2:47 pm
Similar to WordPress permalinks. Does anybody know how to make a .htaccess file that imitates an url.
An example is a site I am building. Pages are selected by going to http://www.doamin.com/d/?p=about
I know this can be done, but have absolutely no idea how to combine .htaccess with php.
I have googled to no avail. I can’t think of any good keywords to use, nothing to describe the issue here.# June 25, 2009 at 4:02 pm
Sorry, I forgot to include the link. :oops:
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html# June 25, 2009 at 5:29 pm
It is a confusing subject because it involves two of the great mysteries of the intarwebz. Apache .htaccess files and regular expressions.
Apostrophe posted a good link about .htaccess so I will post one about regular expressions in general – http://www.regular-expressions.info/# June 29, 2009 at 11:40 am
I recommend anyone that wants to achieve clean urls and is starting a site from scratch should look at using a MVC/MTV framework
CodeIgniter, cakePHP, Zend Framework ect…
Keep in-mind the way they handle the rewrite rule breaks the way most people are accustomed to building web sites….
Traditionally sites follow a folder structure
folder “home” -> file “index.php”
The Rewrite will instead of looking in that folder for that file it treats everything a variable
Rewrites to http://example.com/index.php
Then index.php takes "home/index" as a variable and delivers content accordingly
(Controller = ‘home’, Action = ‘index’)
In addition, this will allow you to define custom uri structures likeCode:$customURI = ‘profile/:userName’;
This will point to the profile controller and give a username variable equal to benjamin allowing you to pull up content about a unique person
Anyways, take a look at it, alot of sites use frameworks like such and for good reason too, very powerful, extensive useful libs and faster development of your sites# January 19, 2010 at 7:31 pm
I’m currently learning CodeIgniter and am having problems with the .htaccess regex part.
From their wiki, I’m using the following RewriteRule:Code:RewriteRule ^(.*)$ index.php?/$1 [L]
Yet it does not work.
You must be logged in to reply to this topic.