Reputation: 3
Trying to use .htaccess to redirect people snooping into my indexs/folders to a page
Ex; if someone found site.com/pics/1.jpg and tried to see site.com/pics they would be redirected to a url of my choosing or homepage
Thanks in advance
Upvotes: 0
Views: 50
Reputation: 40896
To allow browsing to a specific file such as site.com/pics/1.jpg
but prevent the directory url (site.com/pics/
) from showing all files in that folder, place a .htaccess
file in the pics folder and fill it with:
Options -Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^pics/?$ /newpage.html
The -Indexes
will forbid folder surfing, and the RewriteRule
will redirect to site.com/newpage.html
Upvotes: 1