URL Rewrite in PHP

Reply

Join Date: Jan 2005
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

URL Rewrite in PHP

 
0
  #1
Jun 27th, 2005
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.
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: URL Rewrite in PHP

 
1
  #2
Jun 27th, 2005
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.
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: URL Rewrite in PHP

 
0
  #3
Jun 27th, 2005
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.
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: URL Rewrite in PHP

 
0
  #4
Jun 27th, 2005
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.
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 781
Reputation: Zachery has a spectacular aura about Zachery has a spectacular aura about 
Solved Threads: 21
Team Colleague
Zachery's Avatar
Zachery Zachery is offline Offline
The Geek Father

Re: URL Rewrite in PHP

 
0
  #5
Jun 27th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 234
Reputation: PoA is an unknown quantity at this point 
Solved Threads: 8
PoA PoA is offline Offline
Posting Whiz in Training

Re: URL Rewrite in PHP

 
0
  #6
Jun 28th, 2005
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
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 1
Reputation: a-geek is an unknown quantity at this point 
Solved Threads: 0
a-geek a-geek is offline Offline
Newbie Poster

Re: URL Rewrite in PHP

 
0
  #7
Apr 23rd, 2009
An example of how to write a simple rewriting rule:

[URL sipped]
Last edited by Ezzaral; Apr 23rd, 2009 at 4:03 pm. Reason: Snipped url. Keep it spam-free.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 225
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: URL Rewrite in PHP

 
0
  #8
Apr 23rd, 2009
Originally Posted by a-geek View Post
An example of how to write a simple rewriting rule:

[URL snipped]
4 year bump! Drink!
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC