-2

Am having an website with many directories and files. I just want to hide all the sub directories name and file names like https://example.com/folder_01/file.php to https://example.com. I could able to hide a single folder name using rewrite rule in htaccess apache server. Also I tried frame set concept but it shows unsafe script when tried to run the website in browser. Can anyone help me? Thanks in advance.

1 Answers1

0

This isn't possible.

A URL is how the browser asks the server for something.

If you want different things, then they need different URLs.

If what you desired was possible, then somehow the server would have to know that if my browser asked for / then it meant "The picture of the cat" while also knowing that if my browser asks for / then it means "The picture of the dog".

It would be like stopping at a fast food drivethru where you had never been before, didn't know anyone who worked there, and asking for "My usual" and expecting them to be able to know what that was.


You mentioned using frames, which is an old and very horrible hack that will keep a constant URL displayed in the browser's address bar but has no real effect beyond making life more difficult for the user.

They can still look at the Network tab in their browser's developer tools to see the real URL.

They can still right click a link and "Open in new tab" to escape the frames.

Links from search engines will skip right past the frames and index the URLs of the underlying pages which have actual content.


URLs are a fundamental part of the WWW. Don't try to break them. You'll only hurt your site.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I can understand you. But I have developed an web application where am using breadcrumb navigation so I think there is no need to mention the directory listing in the url. I just want a clean url like facebook website. – Jebes Bless Mar 21 '18 at 16:56
  • RewriteRule ^$ folder_name_01/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ folder_name_01/$1 I used this rewrite rule and I could able to hide the foldername_01. But I want to hide all the directories . Is there any alterations that can be made in this rule which can hide all the directories after my domain name?? – Jebes Bless Mar 21 '18 at 16:57
  • @JebesBless — The breadcrumbs are links. They have to point to URLs. Facebook has unique URLs for its different pages. https://i.imgur.com/KN5fgri.png – Quentin Mar 21 '18 at 17:00