Welcome to WebmasterWorld Guest from 54.224.49.217

Forum Moderators: Ocean10000 & incrediBILL & phranque

Trouble loading SVGs in Angular project on Apache

SVG assets are returning 403, presumably due to htaccess

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

New User

joined:July 31, 2017
posts:2
votes: 0


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.
4:14 pm on July 31, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14017
votes: 520


Now, wait. Is this your own server--as implied by the <Directory> section--or shared--as implied by the existence of htaccess?
4:26 pm on July 31, 2017 (gmt 0)

New User

joined:July 31, 2017
posts:2
votes: 0


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?
7:05 pm on July 31, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10977
votes: 84


You might find some clues in the server error log file.
12:49 am on Aug 1, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:14017
votes: 520


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.
1:07 am on Aug 1, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10977
votes: 84


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.
1:16 am on Aug 1, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10977
votes: 84


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?