如何在cakephp网站上连接我的css文件?

时间:2018-03-01 22:37:57

标签: cakephp-2.0

我想使用我的css文件。

我用过

$this->Html->css(array('style'), array('charset'=>'utf-8', 'inline' => false));

但是这段代码一直指向“myPageFolder / css / style.css'”。 不是' myPageFolder / app / webroot / css / style.css'

如何制作代码点/app/webroot/css/style.css

1 个答案:

答案 0 :(得分:0)

尝试以下代码

import { Injectable, Injector } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from 
'@angular/common/http';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import 'rxjs/add/observable/throw'
import 'rxjs/add/operator/catch';

 @Injectable()
    export class TokenInterceptor implements HttpInterceptor {

  constructor(private router: Router) {
 }

intercept(req: HttpRequest<any>, next: HttpHandler):
Observable<HttpEvent<any>> {

if (localStorage.getItem('authToken')) {    
  req = req.clone({
    setHeaders: {
      'X-SDB-AUTH-TOKEN': localStorage.getItem('authToken')
    }
  });

}
return next.handle(req)
  .catch((error, caught) => {
    if (error.status === 401 || error.status === 403) {
       localStorage.removeItem('authToken');  
       this.router.navigate(['/testLogin']);   
    }

    return Observable.throw(error);
  }) as any;
 }  
}

root htaccess yourapp / .htaccess

<?php
    echo $this->fetch('css');
    echo $this->Html->css('style');         
?>

在yourapp / app / .htaccess中找到htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]   
</IfModule>

webroot /app/webroot/.htaccess中的htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]   
</IfModule>

请检查根目录yourapp / index.php

中找到的index.php
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>