Параметры маршрута angularjs с htaccess не включают файл css

0

люди,

Я использую файл htaccess для перенаправления для маршрутизации с представлениями. Everthing отлично работает, если только я не работаю с routeParams. Я получаю журнал, но шаблон не включает файл css. Я получаю эту ошибку:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/angularKamers/kamersite/public_html/email_activatie/29/css/header.css"

JavaScript:

 app.config(function ($routeProvider, $locationProvider) {
        $routeProvider.
                when('/email_activatie/:id/:code', {
                    templateUrl: 'views/email_activatie.html',
                    controller: 'emailActivatieController'
                });
        $locationProvider.html5Mode(true);
    });
app.controller('emailActivatieController', function ($scope, $routeParams) {
   // if I use /email_activatie/29/1060890

    console.log($routeParams.id); //logs 29
    console.log($routeParams.code);// logs 1060890
});

htacces:

    RewriteEngine On

  # If an existing asset or directory is requested go to it as it is
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
  RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
  RewriteRule ^ - [L]

  # If the requested resource doesn't exist, use index.html
  RewriteRule ^ /angularKamers/kamersite/public_html/index.html

Возможно, это/в маршрутизаторе, который не совпадает с моим htaccess. Все идеи?

  • 0
    Достаточно легко просто поставить начальные / перед относительными путями в href чтобы сделать их также абсолютными
  • 0
    @charlietfl Что ты имеешь в виду, можешь привести пример?
Показать ещё 4 комментария
Теги:
.htaccess

1 ответ

0

Этот код должен обслуживать нужные заголовки содержимого и gzip ваш контент, если разрешено

# Rules to correctly serve gzip compressed CSS and JS files.
  # Requires both mod_rewrite and mod_headers to be enabled.
  <IfModule mod_headers.c>
    # Serve gzip compressed CSS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.css $1\.css\.gz [QSA]

    # Serve gzip compressed JS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.js $1\.js\.gz [QSA]

    # Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
    RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]

    <FilesMatch "(\.js\.gz|\.css\.gz)$">
      # Serve correct encoding type.
      Header set Content-Encoding gzip
      # Force proxies to cache gzipped & non-gzipped css/js files separately.
      Header append Vary Accept-Encoding
    </FilesMatch>
  </IfModule>

Соответствующая линия для вас, я думаю, будет:

RewriteRule \.css$ - [T=text/css]
  • 0
    если я скопирую это или воспользуюсь соответствующим. Я получаю сообщение об ошибке, что страница, к сожалению, не существует.
  • 0
    Хммм, у вас включен gzip в вашем httpd.conf?

Ещё вопросы

Сообщество Overcoder
Наверх
Меню