Jump to content

Mod rewrite not working


watsmyname

Recommended Posts

Hello

 

I have following code on htaccess

 

RewriteEngine on
RewriteRule ^([A-Za-z_0-9\-]+[^\.\?/]+)/?$ profile.php?username=$1 [L]

Above code only allows alphanumeric character or alphanumeric characters with period at the end.

 

All i want to do is to re-write http://www.mydomain.com/profile.php?username=john.smith to http://www.mydomain.com/john.smith

username might be johnsmith or john.smith or  john.smith9.doe and so on. SO precisely, alphanumeric characters and periods are allowed.

 

Any help will be much appreciated

Thanks

 

 

If a period is a required character, just add it into the first character set. Incidentally I see you are checking that the request doesn't end in a question mark. The query_string question mark is not part of the string tested against, not I believe a URL safe character.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.