Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [CSS][PHP]RewriteRule gubi CSS'a
Ubermade
post 20.07.2018, 12:57:33
Post #1





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 30.11.2017
Skąd: Leszno, Poland

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


Witam! Ostatnio postanowiłem zoptymalizować linki za pomocą RewriteRule, jednak napotkałem bardzo dziwny błąd.
Napisałem prosty silnik, który bezpośrednio linkuje CSS'a do szablonu, w którym do diva ładowany jest cały kontent strony
  1. <?php
  2. require_once 'utilities/connect.php';
  3. require_once 'utilities/location.php';
  4.  
  5. if(isset($_GET['module'])){
  6. $module = $_GET['module'];
  7. }else{
  8. $module = 'home';
  9. }
  10.  
  11. $moduleDir = 'modules/'.$module.'.php';
  12. $cssDir = 'styles/';
  13. $imagesDir = 'images/';
  14.  
  15. if(file_exists($moduleDir)){
  16. require_once ($moduleDir);
  17. $content = ob_get_contents();
  18.  
  19. require_once ('layouts/basic.php');
  20. }else {
  21. header("HTTP/1.0 404 Not Found");
  22. echo '404';
  23. }

Gdy próbuję wejść pod adres index.php?module=edit_category&id=<id> to wszystko działa, jednak, gdy próbóję wejść tam za pomocą RewriteRule

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteRule home index.php
RewriteRule home index.php?module=home
RewriteRule about-me index.php?module=about_me
RewriteRule my-works index.php?module=my_works
RewriteRule contact index.php?module=contact
RewriteRule list-of-categories index.php?module=list_of_categories
RewriteRule add-category index.php?module=add_category
RewriteRule ^delete-category/([^-]+)$ index.php?module=delete_category&id=$1
RewriteRule ^edit-category/([^-]+)$ index.php?module=edit_category&id=$1
RewriteRule admin index.php?module=admin
RewriteRule panel index.php?module=panel
RewriteRule logout index.php?module=logout

to mimo, że wszystkie działania działają bez zarzutu, to css się niestety nie wczytuje :/
Z góry dziękuję za pomoc smile.gif
Go to the top of the page
+Quote Post
nospor
post 20.07.2018, 12:59:29
Post #2





Grupa: Moderatorzy
Postów: 36 446
Pomógł: 6292
Dołączył: 27.12.2004




bo sciezki do css podaje sie bezwgledne to sie potem nie ma takich problemow

nie:
twojplik.css

a:
http://twojastrona/twojplik.css
ewentualnie
/twojplik.css


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
Ubermade
post 20.07.2018, 13:04:47
Post #3





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 30.11.2017
Skąd: Leszno, Poland

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


Cytat(nospor @ 20.07.2018, 12:59:29 ) *
bo sciezki do css podaje sie bezwgledne to sie potem nie ma takich problemow

nie:
twojplik.css

a:
http://twojastrona/twojplik.css
ewentualnie
/twojplik.css

Zadziałało, dzięki wink.gif Tylko mnie zastanawia, dlaczego wtedy to nie chciało działać, skoro cały czas siedziałem w jednym pliku, z którego szła ścieżka :/
Go to the top of the page
+Quote Post
nospor
post 20.07.2018, 13:07:52
Post #4





Grupa: Moderatorzy
Postów: 36 446
Pomógł: 6292
Dołączył: 27.12.2004




Poczytaj o adresach url bo widze nie ogarniasz.
css lata po sciezce URL a nie po sciezce na dysku. skoro masz url taki
http://twojastrona.pl/kat1/kat2
to sie sciezka URL zmienila


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

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: 18.04.2024 - 18:07