Forum Moderators: phranque
I'm trying to use the mod rewrite rule to change my dynamic url www.domain.com/forums/index.php?showforum=1 to a static url www.domain.com/forums/index/showforum/1 .
Here's what I have in my .htaccess file
RewriteEngine on
RewriteBase /forums/
RewriteRule (.*)/(.*)/(.*)/(.*)\.htm$ /forums/index.php?$1=$2;$3=$4 [T=application/x-httpd-php]
I really have no idea if thats right or not, I just started on this today. The problem is that code does nothing to the urls. I know mod rewrite is loaded on my server, because I'm useing it for some redircts.
I've tried searching the forums and didn't find anything that helped. Anyone have any ideas?
Mod_rewrite will not automatically make your URLs in your forum software 'clean'. You will have to do that part yourself by changing the part of the forum code that writes the URLs.
What mod_rewrite will do is, rewrite your clean URLs back into their original querystring type so that the variables are available to your forum script.
I suggest using URLs similar to this:
site.com/forums/showforum1/
site.com/forums/showforum2/
site.com/forums/showforum3/
This looks better and doesn't appear 'burried' so deep in the filesystem. Then, add these lines in place of your original rules.
RewriteEngine on
RewriteRule ^forums/showforum(.*)/$ /forums/index.php?showforum=$1 [L]
Now you should be good to go.