Sjwdavies
Sjwdavies

Reputation: 4173

.htaccess rewrite rule to change a path to a query string

I'm working on a project and need some help with rewriting some URLS...

We have a URL such as

http://www.example.com/page/a-c/

I need it to be interpreted by the server as:

http://www.example.com/file.php?source=a-c

My .htaccess rewrite skills are not that great!

Upvotes: 1

Views: 3801

Answers (1)

Ravi K Thapliyal
Ravi K Thapliyal

Reputation: 51721

This should do the trick:

RewriteEngine on
RewriteBase /

RewriteRule ^page/([^/]+)/? file.php?source=$1

Upvotes: 15

Related Questions