[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1149
  • Last Modified:

htaccess solution for SEO friendly urls

0
fourice
Asked:
fourice
  • 2
  • 2
  • 2
  • +5
3 Solutions
 
kmcgheeCommented:
If you put the demo, store and blog directories in your htdocs directory they will be as you describe.

www.example.com/demo
www.example.com/blog
www.example.com/store

Maybe I didn't understand the problem correctly?
0
 
Ahmed MerghaniCommented:
0
 
fouriceAuthor Commented:
Hi kmcghee,

Yes, I know. But this is not what I meant.

There should not be any subfolders. These urls are more userfriendly than for example
www.example.com/index.php?page=demo&subpage=store etc.

Hope that it is more clear now, if not let me know.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Julian HansenCommented:
What do these URL's actually point to. If

www.example.com/demo/store/category/product

Do these URL's exist or do you you need to rewrite them to use a script?
0
 
Ahmed MerghaniCommented:
Something like this:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>
0
 
fourckCommented:
Hi fourice,

you are a little confused, let me give you how we normally setup SEO friendly URLs:

1- Currently you are using URLs like this one
www.example.com/index.php?page=demo&subpage=store

Open in new window

the first step is to transform your URLs to the desired format (manually) to be like this one:
www.example.com/demo/store/category/product

Open in new window


without .htaccess, each time you try to click on a link you will get an 404 error page (page not found) and that's normal because you don't have such structure.

using the .htaccess, you can tell the web-server to internally  translate those URLs to the non SEO friendly one, so they are accessible again.

so even if you don't have a demo/store/category directories, .htaccess play the role of a translator.


Htaccess Code



If you want to change URLs like http://mysite.com/index.php?product=productname&price=30 to http://mysite.com/products/productname/30/.

1- change all link to the desired format manually
2- put a .htaccess to translate those URLs,

the .htaccess could be as following:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^products/([a-zA-Z]+)/([0-9]+)/$ index.php?product=$1&price=$2

Open in new window


for advanced modification you check this tutorial:

http://zenverse.net/seo-friendly-urls-with-htaccess/

Good Luck !
0
 
Ray PaseurCommented:
Just curious... Can anyone verify whether this matters at all for SEO any more?  I think Google has changed its algorithms to rely less on the URL and more on the content of the page.  While it may be easier for people to remember these rewritten URLs, I don't think it will do much of anything for page rank.
0
 
Slick812Commented:
I agree with Ray, about going to so much extra trouble for a web addy SEO, if you have crappy content, your web addy SEO will not move you up the search page list, if you have great page content that many people see (hits) you move up the search page.
0
 
Julian HansenCommented:
@Ray and Slick812 - yes and no. Google has said that if you have scripted pages keep them they will index them but warns that you should keep the number of parameters short as not all spiders are as adept at spidering as google.

The other consideration with a SEF Url is that you can put keywords into the path so

www.somesite.com/category/rings/trilogy-diamond-ring.html will inevitably be slightly more advantageous than

www.somesite.com/index.php?category=1&product=231

Having said that I am part of those that resent having to build websites around search engines instead of around the people who use them or at least waste valuable time on the former at the expense of the latter.
0
 
Tony McCreathTechnical SEO ConsultantCommented:
To do it we need a far more precise definition of what you want. My guess...

Your controlling php file is index.php

It accepts the following URL parameters page, subpage, subsubpage, subsubsubpage

e.g.

index.php?page=xxxx&subpage=yyyy&subsubpage=xxxx

parameters are optional apart from page and dependent on the fact the previous parameter exists.

The rewritten URL should be in the forms:

 /page
 /[subpage]/page
 /[subsubpage]/[subpage]/page
 /[subsubsubpage]/[subsubpage]/[subpage]/page

This is just an educated guess on the information you have provide.

Please tell us exactly what you actually want. Then it will be possible to construct code to do it.
0
 
fouriceAuthor Commented:
Sorry for the late response.

I accepted multiple replies as an answer, but fourck's answer got me the best on the way. I'm not completely there, but I hope to get the job done from here.

Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now