Jump to content

Adding backslashes still loads page


mboehler3

Recommended Posts

On deeper pages in my website, adding slashes in-between folders still loads pages. For example:My website is www.example.com/folder/subfolder/In the URL box, I'll edit it to www.example.com////folder//subfolder/And the page loads for both URLs. I only want to make the first URL work. Is there any way to do this?

Link to comment
Share on other sites

I don't think this has to do with web servers. AFAIK, the web browser will automatically attempt to correct the URL if it has extra slashes. However, older browsers may not have this extra feature. In that case, I'm not sure how you'd correct it on the server side....

Link to comment
Share on other sites

Here's what I use to prevent the page from being viewed at multiple URLs, but it only works for PHP pages.

//Code by Ogbus of 0gb.us - http://0gb.us/$_ = explode('?', $_SERVER['REQUEST_URI']);if($_[0] != '/Home/'){ header('Location: /Home/', true, '301 Moved Permanently');die(); }//Prevents the page from being accessed from the wrong URL

Just change '/Home/' to whatever you want the page to be accessed by, minus the domain, and add it to the top of each page. It allows query strings, but no other variations to the URL. I use it to fix capitalization, but I just tested it, and it works on extra slashes too (which means the server is processing the extra slashes, not the browser correcting them). If you're using a different scripting language, it should be possible too. If you are not using server scripts, you might be able to use Apache's mod_rewrite with regular expressions, but coming up with the code for that's a little out of my league.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...