1

I have a bit of trouble with in a folder that laravel is ignoring. In my .htacces I have a line that will ignore my folder called 'doc'.

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

RewriteRule ^(doc) - [L] <-- this one

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

and it works like it should.... kinda.. Example: 'localhost/doc/main.js' works fine if i type it direct into my webbrowser.

Here is my problem: in my /doc i have a 'index.html' that include/require/link some files into it from the doc dir. So in the index.html I have a line

<script data-main="./main.js" src="./vendor/require.min.js"></script>

When I go to 'localhost/doc' I get error that file cant be found (and alot others). linking to 'localhost/vendor/require.min.js'. This should be 'localhost/doc/vendor/require.min.js'

NOTE: this file is generated with ApiDocJS

Anyone have a solution for me, am stuck for about 4 hours now... am getting frustrated


bruno
  • 2,213
  • 1
  • 19
  • 31
Niels Lucas
  • 739
  • 1
  • 12
  • 31

1 Answers1

1

I'll suggest to try to do the same in a different way.

If you're stuck for so long on a problem like that, try changing the way you are following to accomplish your goal.

  • Why that directory?
  • Why ignoring it in .htaccess?
  • Why not separate the logic of the app from the thing I want to hide?
  • Can I configure the libraries I want to use in order to specify a directory?
  • Can I refactor some of my code to prevent the ignore-the-dir-in-htaccess thing? (Since it's not common to do that)

That questions will move you to another direction that may or may not help you with your problem, but that's what I always do on a problem I'm stuck for more than 30 minutes, asking myself for another way of doing the same thing.

Lloople
  • 1,827
  • 1
  • 17
  • 31
  • Q: Why not separate the logic of the app from the thing I want to hide? A: Because one thing is laravel, the other part is something ApidocJs generates something from my laravel app, But I want both project in the same domain – Niels Lucas Oct 22 '17 at 22:48
  • Take in mind that all the laravel logic is outside the `public` folder. So Laravel hides the logic. But in JS that's different, because the logic happens on the client's browser, so the client MUST have access to the logic files. – Lloople Oct 22 '17 at 22:49
  • @Niels Lucas do you use that Javascript library for doc generation? Check out Sami. Different way of doing the same. – Lloople Oct 23 '17 at 00:12