Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Usunięcie frazy .html z linku.
cruzon
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 8.11.2012

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


Witam jak usunąć fraze .html z linku? Wydaje mi się, że jest .htaccess tylko nie wiem jak to ustawić. Chcę mieć coś takiego:
Zamiast nazwa.pl/html.html to nazwa.pl/html
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 11)
b4rt3kk
post
Post #2





Grupa: Zarejestrowani
Postów: 1 933
Pomógł: 460
Dołączył: 2.04.2010
Skąd: Lublin

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


Jeśli chodzi Ci o przyjazne linki, to tak, musisz użyć Mod Rewrite.

Kod
RewriteRule ^([a-zA-Z0-9]+)/$ $1.html [L]


--------------------
Jeśli pomogłem, kliknij proszę 'pomógł'. Dzięki.
Go to the top of the page
+Quote Post
cruzon
post
Post #3





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 8.11.2012

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


A cały tekst w pliku i gdzie go wgrać?
Go to the top of the page
+Quote Post
ratosluaf
post
Post #4





Grupa: Zarejestrowani
Postów: 91
Pomógł: 4
Dołączył: 14.10.2012

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


do .htaccess w katalogu głównym
  1. RewriteEngine on
  2. RewriteRule ^([a-zA-Z0-9]+)/$ $1.html [L]
Go to the top of the page
+Quote Post
cruzon
post
Post #5





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 8.11.2012

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


Not Found

The requested URL /index was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Go to the top of the page
+Quote Post
b4rt3kk
post
Post #6





Grupa: Zarejestrowani
Postów: 1 933
Pomógł: 460
Dołączył: 2.04.2010
Skąd: Lublin

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


Sprawdź przede wszystkim czy mod rewrite u Ciebie działa:

Kod
RewriteRule ^index/$ index.html [L]


Oczywiście index.html musi istnieć.

Poza tym wpisuj ze slashem na końcu, taką regułę napisałem, jak nie chcesz to wywal. Ale jeśli korzystasz z mojej to http://adres.pl/index/



--------------------
Jeśli pomogłem, kliknij proszę 'pomógł'. Dzięki.
Go to the top of the page
+Quote Post
cruzon
post
Post #7





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 8.11.2012

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


Działa ale zobacz co się dzieje:
cruzon.xaa.pl/index/
Go to the top of the page
+Quote Post
b4rt3kk
post
Post #8





Grupa: Zarejestrowani
Postów: 1 933
Pomógł: 460
Dołączył: 2.04.2010
Skąd: Lublin

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


Zapewne chodzi Ci o to, że się np. pliki .css nie ładują? Musisz ustawić bazową lokalizację. W nagłówku HTML:

  1. <base href="/">


oraz w .httaccess:

Kod
RewriteBase /


--------------------
Jeśli pomogłem, kliknij proszę 'pomógł'. Dzięki.
Go to the top of the page
+Quote Post
cruzon
post
Post #9





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 8.11.2012

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


<base href="/"> przed head?
Go to the top of the page
+Quote Post
b4rt3kk
post
Post #10





Grupa: Zarejestrowani
Postów: 1 933
Pomógł: 460
Dołączył: 2.04.2010
Skąd: Lublin

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


Cytat(cruzon @ 9.11.2012, 20:15:04 ) *
<base href="/"> przed head?


Nie przed HEAD, tylko wewnątrz HEAD.


--------------------
Jeśli pomogłem, kliknij proszę 'pomógł'. Dzięki.
Go to the top of the page
+Quote Post
cruzon
post
Post #11





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 8.11.2012

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


Teraz nie działa menu. Cruzon.xaa.pl

Ten post edytował cruzon 10.11.2012, 11:27:46
Go to the top of the page
+Quote Post
b4rt3kk
post
Post #12





Grupa: Zarejestrowani
Postów: 1 933
Pomógł: 460
Dołączył: 2.04.2010
Skąd: Lublin

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


Cytat(cruzon @ 10.11.2012, 11:21:58 ) *
Teraz nie działa menu. Cruzon.xaa.pl


Czemu nie działa? Widzę, że wszystko działa. Poza tym pisze się 'zdobądź' a nie 'zdobyj'.


--------------------
Jeśli pomogłem, kliknij proszę 'pomógł'. Dzięki.
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 Aktualny czas: 19.08.2025 - 17:33