'how to hide folder name from link
domain/pages/asd.php
I have a link in the form of I want to hide the pages folder. People need to write domain/asdf.php on the link and reach the file in the folder, how can I do it?
Solution 1:[1]
Add the following to your .htaccess file
RewriteEngine on
RewriteRule ^pages/(.+)$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) /pages/$1 [END]
This will ensure users can only access the url by the new route only (/asd.php) and not via both (I.e /asd.php & /pages/asd.php).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
