0

hello....
my current url is

categories_name.php?cname=at&t
rewritten url like this.
carriers/at&t
this is htaccess url.
RewriteRule ^carriers/(.*)$ categories_name.php?cname=$1 [L]

above url is working for all like

categories_name.php?cname=all-tel

when variable has '&' symbol then problem occuring. so how to write htaccess url?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by SikoSoft
0

Now I could be wrong with the actual cause of your problem here, but what I do know is that the ampersand has special meaning in most contexts (including .htaccess, PHP and in page URLs). Its literal use should be avoided because when you use it in a URL, the web server is going to treat it as a new part of the query string data (GET data).

For example:

categories_name.php?cname=at&t

What this URL is aying to PHP is:

categories_name.php is the file to open, and to use this as GET data:

cname is at
t is null

You could encode the ampersand using something like urlencode() in PHP, but I personally recommend trimming out any literal ampersands or replacing them with something like "and".

This isn't just something effecting PHP or .htaccess either - it is how all web requests are treated. The ? and & characters have special meaning in URL syntax so their occurrence should either be escaped or avoided in a literal sense.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.