Search code examples
zend-framework.htaccesswamp

Backslash in URL causes 404 error


I have a search form on the page and I use GET method to send data to the server, but when I type backslash and click search, I see a 404 error. It is for "\" in URL. How can I prevent it?

http://127.0.0.1:8080/SelfArea/wpzf/public/\

Apache server configuration htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Windows 7, WAMP Server.


Solution

  • Few things to note:

    Point 1. Your browser should convert backslash to frontslash. Many browsers have "updated stuff" example: you cannot run direct javascript from address bar anymore in Chrome. However, a good programmer will always imagine a user to be more dumb than monkey, so your question makes perfect sense!

    Point 2. If you are accepting parameters then, you might want to strip slashes using:

    Stripslashes Function

    Point 3. This will not be an issue in Linux system because, windows and linux both have different filing structure. Trust me, it will be ok :)

    EDIT:

    PS: You might want to test it on linux machine by putting it on "free hosting services"! that is , if you do not have a server already.