1

I am using php $_GET function to call parameters from the database. And these perameters are usually variable within the url.

E.g. http://localhost:8080/series/dynamics/admin/cleanURL/Apple, where Apple is the variable from the database.

This works fine as long as GET function doesn't encounter a space, however in a real life situation I will have some variable such as "Green Apple" "Red Apple" etc..and URL will like,

http://localhost:8080/series/dynamics/admin/cleanURL/Green%20Apple and in that case I am getting 404 The requested URL was not found on this server error.

What I would like to achieve is to be able to conver whitespace into hyphen or +. I have done it through strreplace or urlencode() however the problem is I am still not able to get rid 404 error.

Just incase if it has anything to do with htaccess below is my code

 Options +MultiViews 
 Rewriteengine on
 RewriteBase /series/dynamics/admin/cleanURL/

 RewriteCond %{REQUEST_FILENAME} !-f [OR]
 RewriteCond %{REQUEST_FILENAME} !-d

 RewriteCond %{THE_REQUEST} /series/dynamics/admin/cleanURL/(\S*)\s [NC]

 Rewriterule ^(\w+)/?$ index.php?product=$1 [L,QSA]
 RewriteRule ^series/dynamics/admin/cleanURL/(.*)$ /$1 [L,NC,R]

 #rewrite group and subgroup e.g. http://.../value1/value2/
 Rewriterule ^([a-zA-Z0-9]+(.*)+)/([^/]+(.*)+)/?$ index.php?product=$1&subgroup=$2 [L,NC,QSA]
Gautam P Behera
  • 171
  • 2
  • 13

1 Answers1

0

a better question is why are you using folder structures that have whitespace? I'd just change the name of the files to be something like Green_Apple and your problem is fixed. It's better practices.

Josh S.
  • 612
  • 3
  • 8