Reputation: 48798
I had the following rewriting set up in my .htaccess file:
RewriteRule ^(\w+)/?$ profile.php?customURL=$1 [NC,L]
It worked great for a-z A-Z 0-9, but now I need to add support for hyphens.
So I changed it to:
RewriteRule ^[a-zA-Z0-9\-]+$ profile.php?customURL=$1 [NC,L]
But now PHP can't see the contents of $_GET["customURL"]
(i.e. it's empty). What have I done wrong?
Upvotes: 1
Views: 49
Reputation: 6346
Change it to:
RewriteRule ^([a-zA-Z0-9\-]+)?$ profile.php?customURL=$1 [NC,L]
Should work now.
Upvotes: 1
Reputation: 727
Looks like you skipped the parantheses to group for $1:
^([a-zA-Z0-9\-])+$ profile.php?customURL=$1 [NC,L]
Upvotes: 0
Reputation: 80649
Change the rule to this:
RewriteRule ^([a-zA-Z0-9\-]+)/?$ profile.php?customURL=$1 [NC,L]
and it works like a charm.
Upvotes: 2