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 Link to comment https://forums.phpfreaks.com/topic/19420-how-to-use-rewrite-a-rule-containing-other-characters-resolved/ 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 Link to comment https://forums.phpfreaks.com/topic/19420-how-to-use-rewrite-a-rule-containing-other-characters-resolved/#findComment-84318 Share on other sites More sharing options...
AdRock Posted September 1, 2006 Author Share Posted September 1, 2006 will this allow - (dashes) too? Link to comment https://forums.phpfreaks.com/topic/19420-how-to-use-rewrite-a-rule-containing-other-characters-resolved/#findComment-84322 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 (_) Link to comment https://forums.phpfreaks.com/topic/19420-how-to-use-rewrite-a-rule-containing-other-characters-resolved/#findComment-84328 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.