簡體   English   中英

找不到GET請求的angularjs slim 404

[英]angularjs slim 404 not found for GET request

我已經瀏覽了這里的相關文章,但似乎無法使我的應用程序正常工作。

我決定使用generator-angular-php快速設置端到端應用程序。

當我使用grunt服務時,該應用程序似乎可以按預期運行,因此我決定將其按原樣放在我的apache服務器上。 我用grunt構建它,然后將dist文件夾中的文件復制到我的/ var / www // public_html /

結構如下:

  • / public_html /
    • index.html
    • 樣式:CSS
    • 視圖:查看局部.html
    • 腳本:angularjs控制器
    • api
      • index.php
      • .htaccess#1
      • 供應商
        • autoload.php
            • index.php
            • .htaccess#2
              • 纖細的php文件,例如Route.php
        • 大量其他目錄,例如。 塞巴斯蒂安,學說...
      • 測試
      • src:Api示例
.htaccess#1如下所示:

<?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(),
        ));
    }
}

第一個index.php包含

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

.htaccess#2如下所示:

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

第二個index.php包含以下php代碼:

<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>

在我的網站的網站啟用文件中,我有:

 <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> 

我啟用了rewrite-mod。

但是,當我在瀏覽器中打開網站時,我得到了:

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

響應:

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

我沒有以任何方式更改代碼,並且由於它可以正常工作,所以我猜它應該在不進行任何更改的情況下正常工作(?)這給了我更多白發,而且我沒有主意...什么我想念!

檢查復制文件的權限和所有權。

當grunt構建並創建最終目錄時,它可能會更改/ dist的權限以及對輸出文件的所有權。 chmod 755 -R網站的html目錄,並可能更改所有者(root?)。

此外,有時將這些生成器配置為發布多個構建版本。...一個用於測試,一個用於實時托管。

例如,grunt測試可能會將圖像輸出到temp目錄,而grunt構建輸出到/ dist / images。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM