找不到GID请求的angularjs slim 404

I have browsed through the related posts here, but i cannot seem to get my application working.

I decided to use generator-angular-php to quickly setup an end-to-end application.

When i use grunt serve the application seem to work as intended, so i decided to put it, as is, on my apache server. I build it with grunt, and copied the files in the dist-folder to my /var/www//public_html/

The structure is as follows:

  • /public_html/
    • index.html
    • styles : css
    • views : view partials .html
    • scripts : angularjs controllers
    • api
      • index.php
      • .htaccess #1
      • vendor
        • autoload.php
        • slim
          • slim
            • index.php
            • .htaccess #2
            • Slim
              • slim php files eg Route.php
        • plenty of other dirs, eg. sebastian, doctrine...
      • tests
      • src : the example Api
The .htaccess #1 looks as follows:
 RewriteEngine On    
 RewriteCond %{REQUEST_FILENAME} !-f    
 RewriteCond %{REQUEST_FILENAME} !-d    
 RewriteRule ^ index.php [QSA,L]    

The first index.php contains

<?php
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
date_default_timezone_set('UTC');

try {

    // Initialize Composer autoloader
    if (!file_exists($autoload = __DIR__ . '/vendor/autoload.php')) {
        throw new \Exception('Composer dependencies not installed. Run `make install --directory app/api`');
    }
    require_once $autoload;

    // Initialize Slim Framework
    if (!class_exists('\\Slim\\Slim')) {
        throw new \Exception(
            'Missing Slim from Composer dependencies.'
            . ' Ensure slim/slim is in composer.json and run `make update --directory app/api`'
        );
    }

    // Run application
    $app = new \Api\Application();
    $app->run();

} catch (\Exception $e) {
    if (isset($app)) {
        $app->handleException($e);
    } else {
        http_response_code(500);
        header('Content-Type: application/json');
        echo json_encode(array(
            'status' => 500,
            'statusText' => 'Internal Server Error',
            'description' => $e->getMessage(),
        ));
    }
}

The .htaccess #2 looks as follows:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA]

The second index.php contains php code to:

-Slim Framework and register its PSR-0 autoloader.
-Instantiate a Slim application
-Define the Slim application routes (get, post, put etc

In my site-enable file for my site i have:

<VirtualHost *:80>
    ServerAdmin hanto899@myphpportfolio.com
    ServerName myphpportfolio.com
    ServerAlias www.myphpportfolio.com
    DocumentRoot /var/www/myPhpPortfolio/public_html
    ErrorLog /var/www/myPhpPortfolio/public_html/error.log
    CustomLog /var/www/myPhpPortfolio/public_html/access.log combined

    <Directory "/var/www/myPhpPortfolio/public_html">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

I have enabled the rewrite-mod.

However, when i open up my site in a browser, i get an:

GET http://myphpportfolio.com/api/features 404 (Not Found)

with the response:

{"status":404,"statusText":"Not Found","description":"Resource \/features using GET method does not exist."}

I haven't altered the code in any way, and since it works durig grunt serve, I am guessing it should work without any alterering (?) This is giving me more gray hairs, and I am out of ideas...what am I missing!

doutui839638
doutui839638 你有没有想出解决方案呢?我使用generator-angular-php构建了一个应用程序,当我部署到我是管理员的服务器时,它可以工作。当我部署到共享的服务器时,它不会;所以我很好奇你想出了什么解决方案?
4 年多之前 回复

1个回答



检查复制文件和所有权的权限。 </ p>

当grunt构建并创建最终目录时,它可能会更改/ dist的输出文件的权限和可能的所有权。 chmod 755 -R你的网站的html目录,并可能更改所有者(root?)。</ p>

此外,这些生成器有时配置为推出多个构建版本....一个用于测试 和一个现场托管。 </ p>

例如,grunt test可能会将图像输出到临时目录,而grunt构建输出到/dist/images.


</ div>

展开原文

原文

Check permissions on the copied file and ownership.

When grunt builds and creates the final directory, it may change permissions and possibly ownership of the output files from /dist. chmod 755 -R the html directory with your website and possibly change owner(root?).

Also, those generators are sometimes configured to put out multiple builds builds....one for testing and one for live hosting.

For example, grunt test might output the images to a temp directory while grunt build outputs to /dist/images.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐