views:

17

answers:

2

I want example.com/23-45 be transformed to example.com?id=23-45

Could you please post the code I should add to .htaccess file to make this work (Is this everything I should do to make this work - add a piece of code to .htaccess file ???)

Thanks a lot!

A: 

You have to have mod_rewrite enabled in Apache's httpd.conf. To use a .htaccess, you also have to have AllowOverride FileInfo and Options FollowSymLinks for the .htaccess directory in the main configuration. See the docs.

After that, the .htaccess in the root docs directory should have:

RewriteEngine on
RewriteRule ^\d+-\d+$ ?id=$0 [B]
Artefacto
I apologise, but have yo tested the second string?
Dan
@Dan sorry, it had a typo.
Artefacto
Your code gave me a 500 error. That's what worked for meOptions +FollowSymLinksRewriteEngine OnRewriteRule ^([0-9\-]+) index.php?id=$0
Dan
A: 

That's what worked for me

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([0-9\-]+) ?id=$0
Dan