PHP Dynamic htaccess

Hi there,

I am wondering how do i generate a dynamic htaccess file using php that has mod_rewrite attached in it

i am using a page to links to members profiles so they will be more Search Engine Friendly

How can i go about doing this

i have this

Options +FollowSymLinks
RewriteEngine on

RewriteRule -cmd-(.*)-mid-(.*)\\.html index.php?cmd=$1&mid=$2

I want it to be dynamic for every member who gets added to my members list?

Any ideas?


doesn’t that work?
It should work if you get the userdata in the PHP file.

you can change your .httacces file with PHP by allowing the PHPdeamon to edit it via fopen and fwrite, but that’s very dangerous…


Depending upon your host, they may not have mod_rewrite enabled (it is NOT enabled by default) so the tutorial Article linked in my signature has info on how to check whether you have it enabled and functioning.

Because your regex did not specify the start or end anchors, if the {REQUEST_URI} contains -cmd-{everything/nothing}-mid-{everything/nothing}.html, it should redirect as you have specified. I would recommend, however, as good coding practice, you add the Last flag to your RewriteRule.