AdRock Posted September 1, 2006 Share Posted September 1, 2006 I am trying to create a rewrite rule for this[url=http://index.php?page=change-password]index.php?page=change-password[/url]and[url=http://index.php?page=my_profile]index.php?page=my_profile[/url]I have used this[code]RewriteRule ^([A-Za-z0-9]+)/?$ index.php?page=$1[/code]which i presume only allows alphanumeric charactersI have tried using[code]RewriteRule ^(.*)/?$ index.php?page=$1[/code]but i lose my link to the external stylesheet so I get no style, the images aren't displayed and none of the links workHow do i change the rule to allow all character including dash and underscore Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 1, 2006 Share Posted September 1, 2006 You'll want to use this:[code]RewriteRule ^([a-zA-Z0-9\-_]+)$ index.php?page=$1[/code]as the rewrite rule, it also allows underscores to Quote Link to comment Share on other sites More sharing options...
AdRock Posted September 1, 2006 Author Share Posted September 1, 2006 will this allow - (dashes) too? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 1, 2006 Share Posted September 1, 2006 Yes, \- means - When you want to allow hyphens in rewrite rule you'll have to escape them (\-) as a hyphen to mod_rewrite has special meaning so you have to escape it.This:[a-zA-Z0-9\-_]Allows alphanumeric characters, a hyphen (-) and an underscore (_) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.