Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z plikiem .htaccess
stanley1984
post
Post #1





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 12.02.2020

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


Witam otóż mój problem wygląda nastepująco. Na stronie index.php mam dwa odnośniki, z ktorych dane pobierane są z bazy danych:

1. <a href=".$row['mlink'].">".$row['miasto']."</a>
2. <a href=".$row['link'].">".$row['tytul']."</a>

Po kliknieciu w odnośnik przechodzimy do stron site.php gdzie wyswietla się zawartość. Plik .htacces zamienia mi tylko aby link wygladal na przyjazny czyli domena.pl/tytul, a nie domena.pl/site.php?link=tytul

Moj plik htaccess:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule (.*) $1.php [L]

RewriteBase /
Options FollowSymLinks
RewriteCond %{HTTP_HOST} ^www.domena.pl(.*) [NC]
RewriteRule ^(.*)$ http://domena.pl/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+)$ site.php?link=$1 [L]

Wszystko działa jeśli klikniemy w ten drugi link, jak klikam w ten pierwszy nic sie nie wyswietla, pytanie co by trzeba zmienic, podejrzewam ze w pliku htaccess, bo dodanie takiej reguły RewriteRule (.+)$ site.php?mlink=$1 [L] nic nie daje. Umiescilem w pliku site.php takie cos ale tez nic nie pomaga, dlatego prosze o pomoc

<?php
if($_GET['mlink'])
require "get_mlink.php";
if($_GET['link'])
require "get_link.php";
?>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
stanley1984
post
Post #2





Grupa: Zarejestrowani
Postów: 12
Pomógł: 0
Dołączył: 12.02.2020

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


jak zmienie recznie ten pierwszy link na <a href=site.php?mlink=".$row['mlink'].">".$row['miasto']."</a> to dziala, ale wtedy w linku mam domena.pl/site.php?mlink=warszawa, a chcem, domena.pl/miasto/warszawa, jak zmienie na <a href=miasto/site.php?mlink=".$row['mlink'].">".$row['miasto']."</a> zeby te linki jak pisali poprzednicy wczesniej sie roznily to mam domena.pl/miasto/warszawa ale nie wyswietla sie nic

Cytat(aras785 @ 20.10.2022, 22:38:49 ) *
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^miasto/([^/]+)$ miasto/site.php?mlink=$1 [L]

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+)$ site.php?link=$1 [L]


Taki pli htacess wywala mi bład po kliknieci w miasto:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at serwer2286199@serwer2286199.home.pl to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 21.11.2025 - 07:17