PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 23rd, 2013, 03:00 PM
dbosleyjr dbosleyjr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 dbosleyjr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 2 sec
Reputation Power: 0
PHP-General - Rewrite URLs to be SEO Friendly

Looking for advice on how to properly rename the URLs on my website to be SEO friendly. The website is PHP with an .htaccess folder in the admin panel. I'm not a PHP guru, but I know a little about editing code.

I'd like to use the best method that is SEO friendly.

Any suggestions?

Reply With Quote
  #2  
Old January 23rd, 2013, 03:53 PM
mwalkowiak mwalkowiak is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 mwalkowiak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 22 sec
Reputation Power: 0
The best way is using dash separated keywords like

category-name/current-page-title

Reply With Quote
  #3  
Old January 23rd, 2013, 04:19 PM
BitZoid's Avatar
BitZoid BitZoid is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 98 BitZoid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 20 m 38 sec
Reputation Power: 1
  • Keep your rewritten URL's directories to a maximum of 2-3 for SEO (i.e.. example.com/dir1/dir2
  • You can appened .html to the end of your main pages (i.e.. example.com/dir1/final_destination.html)
  • Use Keywords in your URLs, that are also present in your content. (i.e.. example.com/articles/article-or-news-title.html)
  • Use dashes in your URL's and not underscores. Search engines recognize dashes as spaces
  • Keep your directories in your URL's open without a trailing slash for pages that just lead to yet another page (i.e.. example.com/category1/morecategoriesafter
  • Follow a consistent URL naming scheme throughout your entire site. Break out the pad of paper and pencil and design a naming scheme that you can follow. Plan, prepare, execute.

Also, I think this thread would do better in the Search Engine Optimization section of this forum.
__________________
-- Success achieved from tribulation --

Last edited by BitZoid : January 23rd, 2013 at 04:25 PM.

Reply With Quote
  #4  
Old January 24th, 2013, 09:36 AM
dbosleyjr dbosleyjr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 dbosleyjr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 2 sec
Reputation Power: 0
Thanks for the advice, but I need to understand how to do the rewrite properly.

1. Would I use the following code to 301 w.cityofficespaces.com/default to w.cityofficespaces.com ?

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^w.cityofficespaces.com/default [nc]
rewriterule ^(.*)$ w.cityofficespaces.com/$1 [r=301,nc]

2. How would I rewrite w.cityofficespaces.com/Search/SearchDetails/24 to become w.cityofficespaces.com/office-space-for-rent-new-york-city/midtown-west/24 ?

Thanks,
David

Reply With Quote
  #5  
Old January 24th, 2013, 11:23 AM
Northie's Avatar
Northie Northie is offline
Square Peg in a Round Hole
Click here for more information.
 
Join Date: Oct 2007
Location: North Yorkshire, UK
Posts: 3,419 Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level)Northie User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 10 h 15 m 39 sec
Reputation Power: 3896
One issue many newbies to .htaccess rewritning stumble on is this:

.htaccess and php don't talk to each other, so just adding URL rewriting to .haccess does not automagically rewrite the outgoing html - you have to do this in your templates.

.htaccess rewriting is for rewriting the incoming requests from a request that does not match a file to a request that does match a file

eg when a user requests

http://www.example.com/friendly/link.html

then the server actually gets

http://www.example.com/index.php?q=friendly/link.html

(for example)

This can be achieved with

Code:

#turn on rewrite engine

RewriteEngine On

#operate on web root

RewriteBase /


#if the request is not an existing file, continue

RewriteCond %{REQUEST_FILENAME} !-f


#if the request is not an existing directory, continue

RewriteCond %{REQUEST_FILENAME} !-d

#do a rewrite.The L option means that no further rules should be processed after this one, if this one executes

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

#(can't remember what the QSA options are about;) )


your templates would then need to make the links to

http://www.example.com/friendly/link.html

instead of

http://www.example.com/index.php?page_id=8
__________________
PHP OOPS! <?php DB::Execute(SQL::makeFrom($_GET))->fetchArray()->FormatWith(Template::getInstance('default'))->printHtml(); ?>

PDO vs mysql_* functions: Find a Migration Guide Here

[ Xeneco - T'interweb Development ] - [ Are you a Help Vampire? ] - [ Read The manual! ] - [ W3 methods - GET, POST, etc ] - [ Web Design Hell ]

Last edited by Northie : January 24th, 2013 at 11:28 AM. Reason: additional code and comments

Reply With Quote
  #6  
Old January 24th, 2013, 12:38 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,698 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 4 h 53 m
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
Quote:
Originally Posted by BitZoid
Also, I think this thread would do better in the Search Engine Optimization section of this forum.

Back when we thought he wanted advice about what they should look like, yes, but since the question is apparently about how to do it this thread here is fine.
Comments on this post
BitZoid agrees: Agree

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - Rewrite URLs to be SEO Friendly

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap