G
G
George2014-11-06 20:59:18
PHP
George, 2014-11-06 20:59:18

How to add "_" character to RewriteCond in .htaccess?

Currently there is this rule:
RewriteEngine on
RewriteCond %{REQUEST_URI} \/([0-9a-z\&\=\.\[\]\{\}\%\-]+)$ [NC]
RewriteRule ^ (.*) /hello.php?query=%1 [L]
It, as experts have already understood, sends from /hsdfs to /hello.php?query=hsdfs
hsdfs is a string that can contain characters 0-9, az, &, =, etc...
I need to add one more character "_" to these characters. But when I convert the second line like so:
RewriteCond %{REQUEST_URI} \/([0-9a-z\&\=\.\[\]\{\}\%\-\_]+)$ [NC]
or so
RewriteCond %{REQUEST_URI} \/([0-9a-z\&\=\.\[\]\{\}\%\-_]+)$ [NC]
I get 500 error...
How to achieve what you want result?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
George, 2014-11-10
@Georgy1

Resolved like this:
RewriteCond %{REQUEST_URI} \/([a-z0-9_[\]{}%&=-]+)$ [NC]

M
My joy, 2014-11-06
@t-alexashka

According to my mystical rule, underscore cannot be at the beginning or end of a list of characters. try moving it 1 character to the left. It should work.
upd0 : maybe I'm driving

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question