Jump to content

How to use rewrite a rule containing other characters [RESOLVED]


AdRock

Recommended Posts

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 characters
I 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 work
How do i change the rule to allow all character including dash and underscore
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 (_)

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.