First of all, apologies if I could have chosen a better category for this post.
I'm currently rewriting and automating a website, written in PHP. At present the product pages are created by running a program that queries the database and creates a static page - e.g. green-widgets.php.
I want the pages to be dynamic, generated by lets say products.php, but for the resulting page name to match the existing page name so as not to lose any search engine presence. The existing page name is in the database.
Can this be achieved by re-writes? I have no knowledge of mod-rewrite, but I've read some of the basic documentation. What I don't understand is how to pass the page name value from the database to .htaccess, if that's how you do it.
Any help would be appreciated.
Thanks
Page name (mod rewrite?)
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Page name (mod rewrite?)
What you will need to do it make a rewrite rule that looks for some pattern and map that to a particular page, like this:
Then in your index.php script (or whatever you name that file) look for $_GET['page'] and use that name to query the database.
This is not a working example. Please search for mod_rewrite and rewrite rules to see exactly how to implement this. But this is the logic you want to follow.
Code: Select all
RewriteEngine On
RewriteRule ^(.*).php$ /index.php?page=$1This is not a working example. Please search for mod_rewrite and rewrite rules to see exactly how to implement this. But this is the logic you want to follow.