when i wrote localhost/site/images/

i can see all images of my site...
how can i stop it...!!

i tried .htaccess with code "deny to all"

but it does not show images when i run the site on browser..!!

What should i do.?

Member Avatar for nileshgr

when i wrote localhost/site/images/

i can see all images of my site...
how can i stop it...!!

i tried .htaccess with code "deny to all"

but it does not show images when i run the site on browser..!!

What should i do.?

In the .htaccess file put:

Options -Indexes

you should create an index.html file with following code in /images directory

<script language="javascript">
window.location='http://localhost/site';
</script>
Member Avatar for nileshgr

you should create an index.html file with following code in /images directory

<script language="javascript">
window.location='http://localhost/site';
</script>

What if the user had disabled JS ?

Better with this:

RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|gif|png|bmp)$
RewriteRule (.*) http://siteurl [L,R=301]

you should create an index.html file with following code in /images directory

<script language="javascript">
window.location='http://localhost/site';
</script>

Good Idea..!!

or instead of javascript.. should i use header('location:index.php');
as user can off javascript..!!

What if the user had disabled JS ?

Better with this:

RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(jpg|jpeg|gif|png|bmp)$
RewriteRule (.*) http://siteurl [L,R=301]

Actually i cant use.. .htaccess because it's not working in my linux server.!! even i check mod_rewrite module in httpd.conf

still its not working..!!

Member Avatar for nileshgr

Actually i cant use.. .htaccess because it's not working in my linux server.!! even i check mod_rewrite module in httpd.conf

still its not working..!!

Apache by default doesn't allow customization of options. Two things you need to check for .htaccess to work:

1. The <Directory> directive for the top-level directory in which docroot resides has the following:

AllowOverride All

2. AccessFileName directive has the value .htaccess

Apache by default doesn't allow customization of options. Two things you need to check for .htaccess to work:

1. The <Directory> directive for the top-level directory in which docroot resides has the following:

AllowOverride All

2. AccessFileName directive has the value .htaccess

Now it's working.. thanks to u n all..!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.