URL Rewriting in htacess

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mzfp2
Forum Contributor
Posts: 137
Joined: Mon Nov 11, 2002 9:44 am
Location: UK
Contact:

URL Rewriting in htacess

Post by mzfp2 »

Hi,

I have been using a rewrite conditon for in my htaccess file for some time now, the condition simply takes a url such as http://alljammin.com/username and translates it to a real url which a script can process.

The code in my htaccess file is as below

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_URI} !index.php
RewriteRule ^(їa-zA-Z0-9_]+)/?$ db/interface/profiles.php?Action=view&username=$1 їNC,L]


However, I now want add a new rule, which im having trouble doing. I need to translate a url such as

http://alljammin.com/forums/101
to
http://alljammin.com/forums.php?forum_id=101

I have tried tweaking the Rewrite rules I am already using, but not having any success, anyone who can help would be a star.

Thanks
Mzfp
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

RewriteRule ^(їa-zA-Z]+)/(ї0-9]+)?$ /($1).php?forum_id=$2
What about this?
mzfp2
Forum Contributor
Posts: 137
Joined: Mon Nov 11, 2002 9:44 am
Location: UK
Contact:

Post by mzfp2 »

Hi

Thanks for your reply, it was very helpful, i used your code with slight changes and solved the problem!

Many thanks once again

Kind Regards
mzfp
Post Reply