Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> htaccess i doklejone zbędne parametry po przekierowaniu
fud
post 4.07.2019, 15:13:03
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 23.02.2010

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


Cześć mam mały problem i proszę o pomoc.
Otóż mój htaccess wygląda z grubsza tak

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^lubieto-([a-z0-9\-\_\.]+)(/[a-z0-9\-\_\.]+)?/?$ index.php?get_wizard=TRUE&kategoria=$1&group=$2 [NC]
RewriteRule ^([a-z0-9\-\_\,]+)/([a-z0-9\-\_,\/]+[^\/])/?$ index.php?get_object=TRUE&name=$2&kategoria=$1 [NC,L]

RewriteCond %{HTTP_HOST} ^mojastrona.pl [nc]
RewriteRule ^(.*)$ http://www.mojastrona.pl/$1 [r=301,nc]


I teraz gdy chcę zrobić przekierowanie dla pojedynczych podstron w prosty sposób np.
Redirect 301 /nazwa_kategorii/stara_strona /nazwa_kategorii/nowa_strona
lub
RedirectMatch 301 /nazwa_kategorii/stara_strona /nazwa_kategorii/nowa_strona

To po przekierowaniu dokleja mi parametry z drugiego RewriteRule i adres w przeglądarce wygląda tak
www.mojastrona.pl/nazwa_kategorii/nowa_strona?get_object=TRUE&name=nowa_strona&kategoria=nazwa_kategorii

Jak zrobić by w adresie nie pojawiało się ?get_object............
Go to the top of the page
+Quote Post
trueblue
post 5.07.2019, 07:58:26
Post #2





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

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


https://kawalekkodu.pl/jak-zgubic-ogon-czyl...ring-i-htaccess


--------------------
Go to the top of the page
+Quote Post
fud
post 5.07.2019, 10:29:37
Post #3





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 23.02.2010

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


Dzięki trueblue.
Problem częściowo rozwiązała mi twoja podpowiedź.
Częściowo dlatego że teraz w linku doklejane jest tylko ?
czyli zamiast
www.mojastrona.pl/nazwa_kategorii/nowa_strona?get_object=TRUE&name=nowa_strona&kategoria=nazwa_kategorii
mam
www.mojastrona.pl/nazwa_kategorii/nowa_strona?
To znaczny postęp thumbsupsmileyanim.gif
przekierowanie robię tak
Redirect 301 /nazwa_kategorii/stara_strona /nazwa_kategorii/nowa_strona?

Może jak bym zrobił przekierowanie za pomocą RewriteRule to może było by dobrze.
Ale chyba tego nie potrafię bo nic mi nie działa albo sypie błędami.

Może jakaś podpowiedź jak zrobić proste przekierowanie za pomocą RewriteRule
Co wstawić przed RewriteRule.
Może co trzeba wpisać w RewriteCond.

Będę wdzięczy za sugestie.
Go to the top of the page
+Quote Post
trueblue
post 6.07.2019, 12:25:27
Post #4





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

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


Pokaż jak obecnie wygląda Twój .htaccess.


--------------------
Go to the top of the page
+Quote Post
fud
post 8.07.2019, 08:39:03
Post #5





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 23.02.2010

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


Dokładnie tak:


RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^lubieto-([a-z0-9\-\_\.]+)(/[a-z0-9\-\_\.]+)?/?$ index.php?get_wizard=TRUE&kategoria=$1&group=$2 [NC]
RewriteRule ^([a-z0-9\-\_\,]+)/([a-z0-9\-\_,\/]+[^\/])/?$ index.php?get_object=TRUE&name=$2&kategoria=$1 [NC,L]

RewriteCond %{HTTP_HOST} ^mojastrona.pl [nc]
RewriteRule ^(.*)$ https://www.mojastrona.pl/$1 [r=301,nc]

Redirect 301 /nazwa_kategorii/stara_strona /nazwa_kategorii/nowa_strona?


<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 30 days"
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/jpg "access plus 30 days"
ExpiresByType image/svg+xml "access plus 30 days"
ExpiresByType text/css "access plus 30 days"
ExpiresByType text/javascript "access plus 30 days"
ExpiresByType application/javascript "access plus 30 days"
ExpiresByType application/x-javascript "access plus 30 days"
ExpiresByType text/xml "access plus 60 minutes"
</IfModule>


<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
Go to the top of the page
+Quote Post
trueblue
post 8.07.2019, 09:48:12
Post #6





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

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


Zamiast przekierowania wstaw 2 linijki:

Kod
RewriteCond %{REQUEST_URI} ^/nazwa_kategorii/stara_strona
RewriteRule .* /nazwa_kategorii/nowa_strona? [R=301]


Tyle, że to przekierowuje URL o dokładnie takiej postaci, czyli "nazwa_kategorii/stara_strona" na "nazwa_kategorii/nowa_strona".
Nie potrzebujesz tam realnych nazw kategorii?

Ten post edytował trueblue 8.07.2019, 09:48:34


--------------------
Go to the top of the page
+Quote Post
fud
post 8.07.2019, 10:52:58
Post #7





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 23.02.2010

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


Dużo tych przekierowań nie będę miał.
Na tą chwilę 3 ale za niedługo będzie ich z 15
No i za każdym razem "nazwa_kategorii" będzie inna.
np.
nazwa_kategorii
nazwa_kategorii1
nazwa_kategorii2
itd

Ten post edytował fud 8.07.2019, 10:55:03
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: 28.03.2024 - 19:13