Hello,

I would like to ask the way to change http://abc.com.hk/article.php?product=1&side=2 to http://abc.com.hk/article/1/2

I just write in .htaccess as below:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

It works only for this link: http://abc.com.hk/article, but not valid for http://abc.com.hk/article/1/2

That's because you need to do something else (I'm pretty sure)..

For example, the code that you have WILL remove .php from the url's (www.abc.com/article.php -> /article) but, because you are requesting variables (using $_GET) you need to provide something else.

The .htaccess works by taking the url: /article/1/2 and just redirects it to: /article?id=1&page_no=2.. for example..

Let me give you an example: http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/

Hope this helps you =)

try this, name this .htaccess and put it to root

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /

RewriteRule ^article/(.+)/([0-9]+)$ article.php?product=$1&side=$2

btw this code only works for that certain pattern article.php/watever/watever, because im also a newbie on htaccess im just still reading right now on the basic parts, maybe the conditional statements in htaccess RewriteCond can do the trick, but i haven't read that part yet :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.