1

I have a structure like this

/ < root folder
/Site/Public/.htaccess
/Site/Public/index.php
/Site/Public/error.php
/Site/Public/images/chat.png

In my htaccess I have disabled access to subfolders and set a default 403 document like so:

ErrorDocument 403 error.php
Options All -Indexes

But the problem is that I cannot get it to pick that error.php file unless I use the full path starting from root. I also tried this

ErrorDocument 403 chat.png

And it doesn't pick that up either just displays a string in both situations. Can anyone tell me how to target that error.php file without using the absolute path?

The experimenting url is localhost/Site/Public/images

php_nub_qq
  • 15,199
  • 21
  • 74
  • 144
  • 1
    Not sure I understand. What exactly do you want to do and what doesn't work, can you clarify? – Pekka Jun 09 '13 at 18:38
  • I want to display error.php when anyone tries to acces /Site/Public/images – php_nub_qq Jun 09 '13 at 18:39
  • 1
    What's wrong with `ErrorDocument 403 /Site/Public/error.php` then? Or `/error.php` if the former doesn't work? – Pekka Jun 09 '13 at 18:40
  • error.php isn't located in the root folder. And this just shows the default forbidden file error. I want to display my enhanced version of that which is in error.php. I can't use `/Site/Public/error.php` because the `Site` folder may change names and I must edit this every time that happens. – php_nub_qq Jun 09 '13 at 18:42
  • Alternatively You could try this: http://stackoverflow.com/questions/2402140/use-a-subdirectory-as-root-with-htaccess-in-apache-1-3 – Nothing Jun 09 '13 at 19:41
  • You need to use Rewrite rules. http://stackoverflow.com/questions/2402140/use-a-subdirectory-as-root-with-htaccess-in-apache-1-3 – Nothing Jun 09 '13 at 19:43

2 Answers2

1

The urls have to be defined relative to the DocumentRoot, which in your case seems to be the same for your sites.

Alternatively you can use full urls that can be resolved by the client.

That may be an alternative for you.

Everything else you need to know can be read in the manual:

http://httpd.apache.org/docs/current/mod/core.html#errordocument

The Surrican
  • 29,118
  • 24
  • 122
  • 168
1

from http://httpd.apache.org/docs/2.2/mod/core.html#errordocument

URLs can begin with a slash (/) for local web-paths (relative to the DocumentRoot), or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser.

any argument that is not a full url (http://www.example.com) or does not start with / will be treated as string.

Amine Hajyoussef
  • 4,381
  • 3
  • 22
  • 26