I’m making a site with custom cms, in php/mysql.
It’s laid out like:
MYSQL Database
Table name
id, title, description, keywords, content
CMs
Connect to DB, list contents of Table
Get id
Edit title, description, keywords, content
Save back to DB
Website
Connect to DB, where title=home
Example of php page
<?php //connect to database ?>
<html>
<title><?php echo $title;?></title>
<meta name="description" content="<?php echo $description; ?>" >
<meta name="keywords" content="<?php echo $keywords; ?>" >
<body>
<?php echo $content; ?>
</body>
<?php include_once("footer.php"); ?>
So the ideas is to connect to the page and supply the title, which will then connect to the database, retrieve the appropriate row from the table and display the page, eg:
http://www.mysite.com/index.php?title=home
Would display the home page of the site.
Is there a way of removing index.php?title= from the url and still pass the variable, so a user would visit http://www.mysite.com/home
I think there is by editing the .htaccess file, but I’m unsure?
You can do it using mod_rewrite. Put this in your .htaccess :
Those line will redirect each url like http://www.mysite.com/var or http://www.mysite.com/var/ to http://www.mysite.cm/index.php?title=var
This redirection will be transparent.
I suggest you to looks some documentation about URL Rewriting and mod_rewrite to best understand those lines, and be able to make your own.