Problems with assets path



  • Hi, i have successfully installed IdeaSpace but when I publish a space, the generated html has wrong path to assets or can resolve it (js,...). Could you please help? Thank you
    Mod rewrite is activated.

    Htaccess looks 💯
    DirectoryIndex index.php

    <FilesMatch "artisan|composer.phar|composer.json|composer.lock|package.json|web.config">
    Order Allow,Deny
    Deny from all
    </FilesMatch>

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

    # Do not allow directory listings
    Options -Indexes
    
    RewriteEngine On
    
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    </IfModule>

    Generated HTML looks:

    EG.
    <!DOCTYPE html>
    <html>
    <head>
    <title>test</title>
    <link rel="shortcut icon" type="image/png" href="http://MYDOMAIN/index.php/favicon.ico"/>

    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes"> <!-- Fullscreen Landscape on iOS -->
    
    <meta name="abstract" content="test" />
    <meta name="description" content="test" />
    <meta name="keywords" content="" />
    <meta name="copyright" content="" />
    <meta name="robots" content="follow, index" />
    
    <meta http-equiv="origin-trial" data-feature="WebVR" data-expires="04/11/17" content="">
    
    <meta property="og:site_name" content="test" />
        <meta property="og:description" content="test" />
    <meta property="og:title" content="test" />
    <meta property="og:type" content="website" />
    <meta property="og:url" content="http://MYDOMAIN/index.php/test/preview" />
    
    <link rel="stylesheet" href="http://MYDOMAIN/index.php/themes/vr-view-360-image-gallery/css/style.css">
    <script src="http://MYDOMAIN/index.php/themes/vr-view-360-image-gallery/js/vrview.min.js"></script>
    

    </head>
    <body>
    <div class="title"><h1>test</h1></div>
    <div id="vrview"></div>
    </body>
    </html>



  • @tanguylefebvre

    Hi,

    the problem is that in your path index.php appears, for example: http://MYDOMAIN/index.php/favicon.ico - index.php must not appear in the path, in any path.

    There is either something wrong with mod rewrite (did you restart your web server?) or the .htaccess file is not read by your web server (is .htaccess readable by your web server user?).

    Let me know.



  • Hi and thank you for replying.
    I have tested mod rewrite and htaccess. Both look to work fine.
    I use PHP 5.6.31as FMP application served by nginx.
    Nginx settings:
    Proxy mode enabled
    Smart static files processing enabled

    Within IdeaSpace CMS, everything looks to work. It is only when I view/preview places that I have the issue. Example: http://vr.totheweb.be/index.php/tilttest (you can check the HTML source code)

    Thank you for your help!



  • @tanguylefebvre
    Nginx is not reading the .htaccess file. You have to configure the rewrite statements in your nginx configuration.

    The URL you posted does not work because index.php must not appear in the path, that's why you have to configure the rewrite with nginx, in order to get rid of the index.php in your path.

    Your nginx configuration should look similar to that (It is not working in the .htaccess file).

    server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;
    
        root /YOUR/PATH/TO/IDEASPACE-ROOT;
        index index.php index.html index.htm;
    
        server_name server_domain_or_IP;
    
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
    
        location ~ \.php$ {
            try_files $uri /index.php =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    


  • Hi Chris, I tried to override Nginx config in Plesk for that very specific domain but can get it to work.

    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/vhosts/hb2626.myinstance.net/totheweb.be/subdomains/vr/httpdocs;
    index index.php index.html index.htm;
    
    server_name server_domain_or_IP;
    
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    

    }

    I got the following error:
    Invalid nginx configuration: nginx: [emerg] "server" directive is not allowed here in /var/www/vhosts/system/vr.totheweb.be/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed

    So I tried without the server directive and without root and location / as well (cause also duplicate error)

    index index.php index.html index.htm;

    server_name server_domain_or_IP;

    location ~ .php$ {
    try_files $uri /index.php =404;
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    But not working either.

    I miss something but can figure what?

    Thank you for your precious help!



  • Your issue is specific to your hosting provider and I don't know how they allow customers to override nginx configurations for virtual hosts. You could contact your hosting provider, or check their docs if available, and ask if they can help you setting up a standard rewrite configuration for nginx for a Laravel PHP system (IdeaSpaceVR uses Laravel). It is quite simple: all you need is getting rid of the index.php in your URL path by setting up a rewrite.

    As a reference, the IdeaSpaceVR setup should be pretty similar to any NGINX Wordpress setup. If you have Wordpress running you could have a look at that configuration.



  • @tanguylefebvre I just saw that someone else had a similar issue: https://forum.ideaspacevr.org/topic/23/404-not-found-on-nginx

    I hope it helps!


Log in to reply