Sitemap, mod_rewrite, MySQL & PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Noodleyman
Forum Newbie
Posts: 23
Joined: Thu Jun 23, 2011 4:49 pm

Sitemap, mod_rewrite, MySQL & PHP

Post by Noodleyman »

Afternoon everybody,

I am trying to find a solution to a problem. I have a database table that contains product data. The total product count varies between 500,000 records and 3,500,000 records daily.

data is searched, results returned and products viewed via a single php page which uses the format "page.php?id=1"

I am looking into using mod_rewrite to allow me to be able to make the URL's more meaningful to improve search engine visibility. The intention is to rebuild a Sitemap daily after the nightly database update.

However, after doing some reading I can see that mod_rewrite takes it's configuration from .htaccess files. So, I have a concern right now, which is how well will the server cope with 3,500,000 extra lines of code? My expectation is that it won't cope at all and it would be a disaster.

Ideally I am looking for a URL that has the product title in it. In my DB product title may NOT be unique, so using the product title to do a product lookup is not an option.

So, there must be an easier solution within PHP, but I am unsure of what that might be at the moment. Does anybody have any suggestions how I can achieve my goal?

Thanks,

Noodle
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Sitemap, mod_rewrite, MySQL & PHP

Post by social_experiment »

Noodleyman wrote:However, after doing some reading I can see that mod_rewrite takes it's configuration from .htaccess files. So, I have a concern right now, which is how well will the server cope with 3,500,000 extra lines of code? My expectation is that it won't cope at all and it would be a disaster.
From what you wrote here i think you understand mod_rewrite incorrectly; mod_rewrite looks for a pattern and then rewrites that pattern ( say 'page.php?id=1') into something cleaner ( page/1). So you would just need to determine the pattern once in the .htaccess, assuming all your urls follow that pattern
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Sitemap, mod_rewrite, MySQL & PHP

Post by califdon »

I think we may have a terminology problem here. Many of your statements are hard to understand. Do you mean that you have a (MySQL?) database that is repopulated daily with up to several million records? And you are planning to execute search queries based on an ID#? How will the user know what ID# to ask for? I'm struggling to picture the operation. As social_experiment said, mod_rewrite and .htacess are techniques to translate URLs, which is unrelated to how many records you may have in a database. Perhaps you would benefit from reading about databases, as well as mod_rewrite (although I'm inclined to think that you are on the wrong track in even thinking about mod_rewrite). There are lots of online tutorials on both those subjects. If you explained to us what you're really trying to accomplish we might be able to get you on the right track.
Noodleyman
Forum Newbie
Posts: 23
Joined: Thu Jun 23, 2011 4:49 pm

Re: Sitemap, mod_rewrite, MySQL & PHP

Post by Noodleyman »

thanks guys.

I figured this out over a beer :)

I was under the impression that I had to add a single rule to .htaccess file for every re-mapped url I wanted to use. This is incorrect.

What I actually did was setup mod_rewrite in a sub folder, "/products".

I created a rule that would forward every request to anything after /products/ to a .php page. The page captures the text fromt he $_GET variable, and then uses that to lookup / process the product information and directs the user to the appropriate data. What I really needed was a single rule, and a processing page.

Its all up and running now and working as I wanted.
Post Reply