htaccess solution for SEO friendly urls

Who is Participating?
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

Open in new window

the first step is to transform your URLs to the desired format (manually) to be like this one:

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 to

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:

Good Luck !
If you put the demo, store and blog directories in your htdocs directory they will be as you describe.

Maybe I didn't understand the problem correctly?
Ahmed MerghaniSoftware EngineerCommented:
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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 etc.

Hope that it is more clear now, if not let me know.
Julian HansenCommented:
What do these URL's actually point to. If

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

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?$1 [L]
<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
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.
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.
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 will inevitably be slightly more advantageous than

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.
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



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

The rewritten URL should be in the forms:


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.
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.