Forum Moderators: phranque

Message Too Old, No Replies

Trouble loading SVGs in Angular project on Apache

SVG assets are returning 403, presumably due to htaccess

         

rsodhia

2:54 pm on Jul 31, 2017 (gmt 0)

5+ Year Member



I've put my first Angular project live, serving on Apache. I found an htaccess to use somewhere (don't remember where now...) to point all hits to the index, unless they are existing files.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>


Unfortunately, I suck with htaccess files. With this one, I can access any Angular routes, as expected, however, all my SVG files come up 403:

Forbidden

You don't have permission to access /assets/cross.svg on this server.
Server unable to read htaccess file, denying access to be safe


Here are the directory rules:

<Directory /var/www/opweekends.api/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>


The files are owned by the correct group, and are all set to 664, as are all my files, so I can't figure out why CSS and JS files load, but SVGs 403.

I'd love some advice/tutelage on where I've gone wrong.

lucy24

4:14 pm on Jul 31, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Now, wait. Is this your own server--as implied by the <Directory> section--or shared--as implied by the existence of htaccess?

rsodhia

4:26 pm on Jul 31, 2017 (gmt 0)

5+ Year Member



Its a VPS I own. Why does an htaccess imply a shared server? Isn't an htaccess just local rules rather than a <Directory> being global?

phranque

7:05 pm on Jul 31, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



You might find some clues in the server error log file.

lucy24

12:49 am on Aug 1, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why does an htaccess imply a shared server?

Anything that can be done in htaccess can be done in a <Directory> section of the config file. There are situations where htaccess may be appropriate--for example, in a test directory--but in general you wouldn't use htaccess if you've got the option of config. And, since it's your own (VP) server, you definitely don't need the <IfModule> envelope. You already know you're got the module. Whether the -f and -d tests are necessary or appropriate is a whole nother issue; I can't think of any way that it would be connected to the SVG problem.

You might find some clues in the server error log file.

I've never found any LogLevel setting that provides more information than "request denied due to server configuration". (Thank you, Apache. That much I could have figured out unaided.)

If the 403 happens to originate in mod_rewrite, you might be able to run a RewriteLog and see what that tells you.

phranque

1:07 am on Aug 1, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Here are the directory rules:

<Directory /var/www/opweekends.api/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>


Why does an htaccess imply a shared server?


Anything that can be done in htaccess can be done in a <Directory> section of the config file.

you could also say the <Directory> directive can only be specified in config file context, access to which usually implies a dedicated server.

phranque

1:16 am on Aug 1, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Server unable to read htaccess file, denying access to be safe

did you check ownership and permissions of the /assets/ directory and the /assets/,htaccess file?