Forum Moderators: phranque
Let me explain. I've started using php pages and MySql on my site. The php seems relatively easy for me (a blessing after struggling thru CSS and apache directives). But obviously, being new to php, there may underlying issues about which I am clueless.
Here's an example. I've replaced several really long drop down lists on one of my pages with a db load of those options. How nice. I can maintain my items and prices in a single place, and any changes are immediately served. I don't have to modify option lists on multiple pages anymore! How nice. So lets call my new php page ITEMS.PHP, and it has an html equivalent document of ITEMS.HTML.
From the server I rewrite all requests for ITEMS.HTML to ITEMS.PHP, with no server response code. Like this:
RewriteRule ^items\.html$ h**p://mydomain/items.php [L]
So when I request ITEMS.HTML, I'm served ITEMS.PHP and my browser tells me I'm looking at ITEMS.HTML. Slick.
But I have 5 questions for this scenario.
1) I assume that spiders as well as users are getting the php page, so any content I want indexed should be in my php document. Valid assumption or newbie misunderstanding?
2) Is there any reason to keep the html version of the page around?
3) This looks like cloaking, smells like cloaking.. it must be cloaking. Am I facing any unknown (to me - my site) problems?
4) When I rewrite these in htaccess, I'm doing it near the top, before I do any other rewrites for the html file. Huh? Yes, I have other rewrites in place for the same html document, because 1) it has been placed in a new sub-domain and 2) it has been renamed. FWIW, I have done that rename with a R=301 flag. I assume that the rewrite to php should occur *before* any other rewrite. Good assumption?
5) I've asked this twice now and never seen a reply. Either I missed a reply, or the question is so obvious it shouldn't be asked. Here goes... What if I can't access my db? Obviously this would cripple my page.. ie., no items available in a drop down list, just for starters. Is there a method to force a fallback to the html page in this sitution?
What if I can't access my db? Obviously this would cripple my page
Yes, it's obvious. If your databse isn't working, you will have not pages.
You might want to make your initial default home page a vanilla HTM page so it will always load.
1) I assume that spiders as well as users are getting the php page, so any content I want indexed should be in my php document. Valid assumption or newbie misunderstanding?
The RewriteRule is executed on the server to control what is sent down the line. There is no reason why the bots should see anything different to the user.
2) Is there any reason to keep the html version of the page around?
Perhaps as a backup! Even if you were to have a problem with mysql (why should you, mind you), these would not be accessed, as the RewriteRule will override the backup of the original .html files, however you would be in a position to remove the .htaccess and revert to your original site.
3) This looks like cloaking, smells like cloaking.. it must be cloaking. Am I facing any unknown (to me - my site) problems?
I can see no reason why. Cloaking is usually used to serve up one set of pages to a search engine, which are nasty spammy pages specifically designed for ranking purposes, then a second pleasing to the eye (or perhaps even a non related) set of pages to the surfer.
Regards
Shady
If it makes you feel any better, I run a pretty large site (30,000+ pages), and my home page is 50% or better dynamic - php/mysql, pulls visible content from two different databases. If PHP or mysql quit working I'd be teats up for a while - but it's been fine for several years. I do have a good hosting service. I have a few pages that would be crispy-fried if the php/mysql didn't work
I try to put my pages together so that if there's a db problem, the user will get at least the framework of the page, the menu, and basic options - even if all the rest of it doesn't work. If you have a decent host, you can bet that if something goes down, they'll be sweating blood till they get it fixed. I have had the occasional outage (server, not php or mysql), but not for more than a few minutes at a time. They switch to a backup pretty quick.