search engine friendly urls

rgb192
rgb192 used Ask the Experts™
on
I am using query string urls

website.com/category.php?a=apples
website.com/category.php?a=oranges
website.com/category.php?a=grapes

how can I change these urls to be search engine friendly

also in the php I use a get statement in the begining of code
$a=$_GET['a']
would there be a different way to do this if I have to use search engine friendly url

and why is a url search engine friendly, what is the difference
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
PHP Development Team Leader
Commented:
search engine friendly url (shortly SEF links) are commonly done with apache .htaccess modrewrite engine.

What you want is getting visitor from a link like

www.website.com/buy-fresh-apples.html

and serve them

website.com/category.php?a=apples

without they see this.

Right?


If so , just create a file named .htaccess in the root of your site.
and add lines similar to this in it ....

RewriteRule ^([._-a-zA-Z0-9]*)\.html$ category.php?a=$1 [QSA,L,NC]

this redirects any xxxxx.html page to category.php?a=xxxxx
if you need more complex rewrite rules just drop a line to me ....

NOTE : QSA flag at the end will make you still use
www.website.com/buy-fresh-apples.html?coupon_id=2as7as67fa6
creating  $_GET["coupon_id"]...

Best Regards...

Author

Commented:
How would I do this in windows. And could I still use the a=apples as a variable throughout the new page
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Most Valuable Expert 2011
Top Expert 2016
Commented:
Actually, search engines are smart enough that they don't care about the URL nearly as much as they care about the page title, content, and the number of other credible sites that point to your web pages.  In my experience, there is zero SEO value to changing the URLs.  You might, however, make the URLs more memorable to human beings.  If your site is well organized now, I would not waste any time on this exercise.
Erdinç Güngör ÇorbacıPHP Development Team Leader

Commented:
How would I do this in windows. And could I still use the a=apples as a variable throughout the new page

You can do same on windows too. just make sure your apache configuration enables modrewrite engine .
And yes you can still use old style links to reach that page both works.

Author

Commented:
different opinions, which I think could both be correct

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial