| | |
URL Rewrite in PHP
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Is there any way I can convert dynamic URL into static URL in php? i.e. convert php file into html so that the page is search engine friendly. For example:
Change this: http://mysite.com/pagename.php
To this: http://mysite.com/pagename
or this: http://mysite.com/pagename.html
I know there is something called mod_rewrite in Apache, but not sure how it works and whether it's related to what I want.
Thanks for any comment.
Change this: http://mysite.com/pagename.php
To this: http://mysite.com/pagename
or this: http://mysite.com/pagename.html
I know there is something called mod_rewrite in Apache, but not sure how it works and whether it's related to what I want.
Thanks for any comment.
Ecommerce-Web-Store.com Building Your e-Business.
Yes, mod_rewrite is what you want if you are using Apache.
If anybody has any proof, I'd like to see it, but the official word from Google and others is that data-driven content (.ASP, .PHP, .JSP, etc.) is not a problem for their spiders. The only problem for spiders associated with data-driven pages is speed. A spider obviously "browses" your site a lot faster than a human. It may request a dozen pages in a single second. Spiders are not as patient as most humans, either. If your page takes 5 seconds to return--whether static or data-driven, the spider may consider the link bad and move on.
My point is that jumping through hoops to make your data-driven pages LOOK like static pages doesn't help your pages load any faster--which is the real issue with search engines--at least Google anyway.
Google has a Facts & Fiction page here that explains they can index dynamic pages.
http://www.google.com/webmasters/facts.html
At least for google, querystrings are not an issue either, although they do recommend you keep your querystrings short with only a few parameters.
Another "secret" is that if the only way to get to your pages is via a search on your site, then a spider will never find them. You do need every page that you want indexed somehow linked from another page. For example, if your site sells fruit, and the only way for me to reach your fruit_detail.php?fruit=apple page is by searching your inventory for "apple", then a bot will not find this page. However, if I can click on "Inventory" in your menu, then click "Apples" on your page listing all the fruit you sell, a bot can follow these links, too. (This assumes your menu is not generated by javascript, does not require javascript to navigate, and is not a Flash movie menu.)
This is a huge topic, and should be discussed in http://www.daniweb.com/techtalkforums/forum45.html, but one last tip I can offer is to remember you need standard links to your content. If a link has a target like <a href="javascript:LoadPage('fruit.htm')">Fruit</a>, a spider will not be able to follow this link since they cannot run client-side script.
If anybody has any proof, I'd like to see it, but the official word from Google and others is that data-driven content (.ASP, .PHP, .JSP, etc.) is not a problem for their spiders. The only problem for spiders associated with data-driven pages is speed. A spider obviously "browses" your site a lot faster than a human. It may request a dozen pages in a single second. Spiders are not as patient as most humans, either. If your page takes 5 seconds to return--whether static or data-driven, the spider may consider the link bad and move on.
My point is that jumping through hoops to make your data-driven pages LOOK like static pages doesn't help your pages load any faster--which is the real issue with search engines--at least Google anyway.
Google has a Facts & Fiction page here that explains they can index dynamic pages.
http://www.google.com/webmasters/facts.html
At least for google, querystrings are not an issue either, although they do recommend you keep your querystrings short with only a few parameters.
Another "secret" is that if the only way to get to your pages is via a search on your site, then a spider will never find them. You do need every page that you want indexed somehow linked from another page. For example, if your site sells fruit, and the only way for me to reach your fruit_detail.php?fruit=apple page is by searching your inventory for "apple", then a bot will not find this page. However, if I can click on "Inventory" in your menu, then click "Apples" on your page listing all the fruit you sell, a bot can follow these links, too. (This assumes your menu is not generated by javascript, does not require javascript to navigate, and is not a Flash movie menu.)
This is a huge topic, and should be discussed in http://www.daniweb.com/techtalkforums/forum45.html, but one last tip I can offer is to remember you need standard links to your content. If a link has a target like <a href="javascript:LoadPage('fruit.htm')">Fruit</a>, a spider will not be able to follow this link since they cannot run client-side script.
Troy, that's really helpful!
I realise the search engine can search through dynamic site, but not many people convince about this, especially those non-programmers. this is why I try to have html version to convince my clients.
I realise the search engine can search through dynamic site, but not many people convince about this, especially those non-programmers. this is why I try to have html version to convince my clients.
Ecommerce-Web-Store.com Building Your e-Business.
I developed an ASP site for a client years ago. The site is still in use today. It is an ASP site using a SQL Server database. The site has only 5 ASP scripts that produce over 250 data-driven pages. So all the "page" URLs are similar to trip.asp?S=14&L=57. Although the pages load very fast, I read that search engines may not search ASP pages, so I wrote a powerful (but surprisingly simple) script that generates a static HTML site from the ASP site. It crawls the site like a spider and generates a static .htm version of every dynamic page. Now, about once a week, the client runs the "generate static site" utility to update the site with recent data changes. The result is that I've not seen any improvement in search engine ranking. The site was indexed before, just 100s of hits down in the results. This has not changed.
I know there is a lot more to SEO than static vs dynamic, but my point is that in my experience and from what I read from Google, static vs dynamic does not matter.
I know there is a lot more to SEO than static vs dynamic, but my point is that in my experience and from what I read from Google, static vs dynamic does not matter.
They "prefer" .html pages over dynamic pages, but Google doesn't care, they spider forums just fine, take a look at vBulletin.com for example, ALOT is indexed
Firefox: no, its not the end all solution, it has its own issues and in time it will be just as insecure as IE, when its hit Firefox 6, if it makes it that far. Oh, and AOL pays for it, incase you didn't know.
Microsoft & Windows: If you hate it so much, move to linux, or bsd, or anything else, stop complaning and move on.
Good starting places: Gentoo Novell SUSE Fedora Core Apple
Microsoft & Windows: If you hate it so much, move to linux, or bsd, or anything else, stop complaning and move on.
Good starting places: Gentoo Novell SUSE Fedora Core Apple
•
•
Join Date: Jul 2004
Posts: 234
Reputation:
Solved Threads: 8
•
•
•
•
Originally Posted by zippee
Change this: http://mysite.com/pagename.php
To this: http://mysite.com/pagename
or this: http://mysite.com/pagename.html
http://mysite.com/pagename.html
Both will work in mod_rewrite.
As for http://mysite.com/pagename, try
RewriteRule ^pagename pagename.php
As for http://mysite.com/pagename.html, try
RewriteRule ^pagename.html pagename.php
There is an another option you can also try called php pathinfo. http://www.tutorio.com/tutorial/php-...-friendly-urls
Hope it helps.
Last edited by Ezzaral; Apr 23rd, 2009 at 4:04 pm. Reason: Snipped url from quoted message.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
![]() |
Similar Threads
- PHP URL variables and if statement (PHP)
- How can I send variables from a PHP script to another URL using POST without......... (PHP)
- SMF url rewrite (Existing Scripts)
Other Threads in the PHP Forum
- Previous Thread: People online in a site using php
- Next Thread: Is there a way around writing data via http: instead of absolute paths?
| Thread Tools | Search this Thread |
ajax apache api array beginner binary body broken cakephp checkbox class cms code cookies cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert interactive ip javascript job joomla js limit link login mail mediawiki menu mlm mobile msqli_multi_query multiple mycodeisbad mysql navigation oop outofmemmory paging parse paypal pdf php problem procedure query radio ram random recursion regex remote script search server sessions sms source space sql stored subdomain syntax system table tutorial unicode update upload url validator variable video web webapplications websitecontactform xml youtube






