Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript][CSS][PHP]Przyjazne linki - nie widzi plików css i js
stepien
post 7.08.2018, 12:36:51
Post #1





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 19.07.2015

Ostrzeżenie: (0%)
-----


Witam.

Pisze stronę internetową i mam taki problem

htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

Klasa root

<?php

class root {

public $class;
public $action;
public $params;


public function __construct() {

$routParts = explode("/", $_GET['url']);

$this->controller = 'c'.$routParts[0];
$this->action = isset($routParts[1]) ? $routParts[1] : "index";

array_shift($routParts);
array_shift($routParts);

$this->params = $routParts;;
}

public function run(){

$sys = new $this->controller();
$sys->{$this->action}($this->params);
}
}

?>


Linki:


news i news/add

Przy pliku new widziane są jc i css
Natomiast jak klikam news/add to nie dziwidzi js i css.
Jak to rozwiązać ten problem?
Go to the top of the page
+Quote Post
dreamit
post 7.08.2018, 12:40:03
Post #2





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 15.07.2018

Ostrzeżenie: (0%)
-----


Przyczyną może jest dołączenie pliku bez / na początku odnośnika gdzie się znajduje??

jak dołączasz plik css np.
zamiast:
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
zrób z ukośnikiem
<link rel="stylesheet" type="text/css" href="/style.css" media="screen" />

Ten post edytował dreamit 7.08.2018, 12:40:41
Go to the top of the page
+Quote Post
stepien
post 7.08.2018, 13:07:33
Post #3





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 19.07.2015

Ostrzeżenie: (0%)
-----


Nie działa.
Go to the top of the page
+Quote Post
viking
post 7.08.2018, 13:21:23
Post #4





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Spróbuj:

Cytat
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*)$ /ndex.php?url=$1 [NC,L]

A jakie masz adresy w konsoli przeglądarki dla js i css?


--------------------
Go to the top of the page
+Quote Post
stepien
post 7.08.2018, 15:38:41
Post #5





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 19.07.2015

Ostrzeżenie: (0%)
-----


Nie działa

Konsola:
<link href="/backend/css/szablon.css" rel="stylesheet">
<script src="../js/jquery.js"></script>
<script src="../js/validate.js"></script>
Go to the top of the page
+Quote Post
viking
post 7.08.2018, 15:48:45
Post #6





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Co próbuje wczytać w zakładce sieć?


--------------------
Go to the top of the page
+Quote Post
stepien
post 7.08.2018, 16:07:38
Post #7





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 19.07.2015

Ostrzeżenie: (0%)
-----


<a href="news/add">Dodaj</a>

A powinno być

<a href="szkola2/news/add">Dodaj</a>

W pliku mam

<a href="news/add">Dodaj</a>

w url pokazuje:

http://localhost/szkola2/news/add

Nie wiem co robie zle.
Go to the top of the page
+Quote Post
viking
post 7.08.2018, 16:46:05
Post #8





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


A szkoła ma się magicznie wyczarować? Nie ma w linku to skąd nagle ma być w adresie?


--------------------
Go to the top of the page
+Quote Post
stepien
post 7.08.2018, 17:28:25
Post #9





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 19.07.2015

Ostrzeżenie: (0%)
-----


Mam tak nazwane folder w htdocs i mi pokazuje. Juz nie wiem co robie zle.
Go to the top of the page
+Quote Post
trueblue
post 7.08.2018, 17:40:15
Post #10





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


Cytat(stepien @ 7.08.2018, 17:07:38 ) *
<a href="news/add">Dodaj</a>

A powinno być

<a href="szkola2/news/add">Dodaj</a>

Dlaczego uważasz, że powinno być, skoro piszesz, że w adresie właśnie jest /szkola2/:

Cytat(stepien @ 7.08.2018, 17:07:38 ) *

?

Stronę uruchamiasz z katalogu /szkola2/, ścieżki masz względne, więc URL jest "sumą" adresu, z którego uruchamiasz i ścieżki względnej.
Tu akurat wszystko jest ok.


--------------------
Go to the top of the page
+Quote Post
viking
post 8.08.2018, 07:57:43
Post #11





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


Kod
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]

RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L]


--------------------
Go to the top of the page
+Quote Post
leonpro778
post 8.08.2018, 08:10:56
Post #12





Grupa: Zarejestrowani
Postów: 146
Pomógł: 19
Dołączył: 1.03.2012

Ostrzeżenie: (0%)
-----


Może będzie łatwiej gdy przedstawisz tutaj swoją strukturę katalogów?
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 16.04.2024 - 11:31