LIGHT
LIGHT

Reputation: 5712

.htaccess can't read url with %20

This is how my htaccess file look right now:

RewriteEngine On
RewriteRule ^([\sa-zA-Z0-9_-]+)$ view.php?folder=$1
RewriteRule ^([\sa-zA-Z0-9_-]+)/$ view.php?folder=$1
RewriteRule ^([\sa-zA-Z0-9_-]+)\.html$ view.php?page=$1

It accepts the url as:

http://localhost/new.html to view.php?page=new
http://localhost/something to view.php?folder=something
http://localhost/something/ to view.php?folder=something

but it is not working for url as:

http://localhost/something%20else
http://localhost/something%20else/

it should be view.php?folder=something%20else

Upvotes: 0

Views: 507

Answers (1)

Martin
Martin

Reputation: 22760

According to this answer you should be using a url rewrite flag on your htaccess rewrite.

(shameless quote of link to follow:)

Try adding the B rewrite flag. This flag tells mod_rewrite to escape backreferences, the documentation says this:

_rewrite has to unescape URLs before mapping them, so backreferences will be unescaped at the time they are applied. Using the B flag, non-alphanumeric characters in backreferences will be escaped.

Upvotes: 1

Related Questions