yans Posted January 28, 2021 Share Posted January 28, 2021 Hi. In short I have long url domain.eu/index_pl.php?src=home and i would like to have domain.eu/home Pls tell me where i can put my url on this bottom example? RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z-_0-9]+)/([a-zA-Z-_0-9]+)/?$ index.php?page=$1&id=$2 [L] RewriteRule ^([a-zA-Z-_0-9]+)/?$ index.php?page=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/ Share on other sites More sharing options...
requinix Posted January 29, 2021 Share Posted January 29, 2021 Fix the RewriteConds so they're on separate lines and fix the RewriteRules to use the correct rewrite destinations according to the "long" URLs you want. Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584098 Share on other sites More sharing options...
yans Posted January 29, 2021 Author Share Posted January 29, 2021 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^home/([a-zA-Z-_0-9]+)/?$ index_pl.php?src=home=$1[L] RewriteRule ^([a-zA-Z-_0-9]+)/?$ index_pl.php?src=home=$1 [L] 5 hours ago, requinix said: Fix the RewriteConds so they're on separate lines and fix the RewriteRules to use the correct rewrite destinations according to the "long" URLs you want. Hi. Thanks for your reply. I put this on that way, but still my link url is long http://www.grimlord.eu/index_pl.php?src=home Requinix I would like to appear that url http://www.grimlord.eu/home Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584105 Share on other sites More sharing options...
requinix Posted January 29, 2021 Share Posted January 29, 2021 Apache does not fix your long URLs to be short. What it does is allow you to use short ones. In other words, you're thinking about URL rewriting backwards: short URL goes into the browser, long URL is what runs on the server. So go to /home and see what happens. Spoiler: it won't work. 1. Try adding an [R] flag to both of those RewriteRules so you can see what is happening. 2. RewriteConds only affect the single next RewriteRule. If you want them to apply to two RewriteRules then you need to use two copies of them. 1 Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584107 Share on other sites More sharing options...
yans Posted January 29, 2021 Author Share Posted January 29, 2021 OK I changed (L) on (R) and still does not work (white screen) when i type grimlord.eu/home RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^home/([a-zA-Z-_0-9]+)/?$ index_pl.php?src=home=$1[R] Yes I understand. thats right. In generally im going to such result for examplehttps://www.clannad.ie/shop What can I do in this situation if I have in main file index.pl.php (in section body) <area shape="rect" coords = "15,15,115,35" href="index_pl.php?src=home" alt="Home" target="_self"> and also.. <li><a href="http://www.grimlord.eu/index_pl.php?src=home">start</a></li> You know what I mean.. When I click button START on website i see url http://www.grimlord.eu/index_pl.php?src=home adress from serwer. And I dream about see http://www.grimlord.eu/home or http://www.grimlord.eu/links ...etc. Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584110 Share on other sites More sharing options...
requinix Posted January 29, 2021 Share Posted January 29, 2021 A white screen means your PHP code broke. Look in your server error logs to find a reason why. Also, when you tried going to /home, did you watch what happened in the address bar? You saw it change, right? Did you pay close attention to what the new URL was? As for those links, the solution is to fix them. Don't write index_pl.php?src=home. Do write /home. 1 Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584133 Share on other sites More sharing options...
yans Posted January 30, 2021 Author Share Posted January 30, 2021 On 1/29/2021 at 11:25 PM, requinix said: A white screen means your PHP code broke. Look in your server error logs to find a reason why. Also, when you tried going to /home, did you watch what happened in the address bar? You saw it change, right? Did you pay close attention to what the new URL was? As for those links, the solution is to fix them. Don't write index_pl.php?src=home. Do write /home. Now I have in htaceess code show below.. And all is Well correct! RewriteEngine On RewriteRule ^home$ index_pl.php?src=home [R] Requinix my main title probably is wrong described ... My host WEBD sent me my lost code from 4 days ago when I tryed changed the code not for a NICE link but STATIC url What I mean.. For example when you enter into website you see not www.clanad.ie/index.php.etc etc you can see static automaticly shown url like this https://www.clannad.ie/live Im looking code for that result in url http://www.grimlord.eu/home when someone enter to website not http://www.grimlord.eu/index_pl.php?src=home Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584165 Share on other sites More sharing options...
requinix Posted January 31, 2021 Share Posted January 31, 2021 2 hours ago, yans said: Now I have in htaceess code show below.. And all is Well correct! RewriteEngine On RewriteRule ^home$ index_pl.php?src=home [R] But what about other pages? You'd have to add RewriteRules for every single one. Go back to the version you had just before this one and see if you can't fix it in a different way. A way that would allow you to use the same URL pattern for more than one page. You'll also have to deal with that white page, because even if you don't have a page like /foo, you at least need to make sure index_pl.php?src=foo doesn't crash in some bad way. 2 hours ago, yans said: Im looking code for that result in url http://www.grimlord.eu/home when someone enter to website not http://www.grimlord.eu/index_pl.php?src=home First step is fixing all of your URLs so that you do not try to give people URLs like /index_pl.php?src=home. You have to change those yourself. It will not happen automatically, Apache will not scan through your HTML and fix your links for you. Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584166 Share on other sites More sharing options...
yans Posted January 31, 2021 Author Share Posted January 31, 2021 19 hours ago, requinix said: But what about other pages? You'd have to add RewriteRules for every single one. Quote RewriteEngine On RewriteRule ^grimshop$ index_pl.php?src=shop [R=301] RewriteRule ^start$ index_pl.php?src=home [R] RewriteRule ^biografia$ index_pl.php?src=formacja&sub=historia [R] RewriteRule ^dyskografia$ index_pl.php?src=material [R] RewriteRule ^galeria$ index_pl.php?src=galeria [R] RewriteRule ^recenzja$ index_pl.php?src=media [R] RewriteRule ^linki$ index_pl.php?src=linki [R] RewriteRule ^koncerty$ index_pl.php?src=konfrontacje [R] RewriteRule ^kontakt$ index_pl.php?src=kontakt [R] Ok. I have them all, and it work. Now I can send nice link on other site. My second qestion is what can I do if I would like to see adress like this ON MY WEBITE in section url www.grimlord.eu/start Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584180 Share on other sites More sharing options...
requinix Posted February 2, 2021 Share Posted February 2, 2021 As far as I can tell, either you're asking how to do something you already know how to do, or you're asking how to do something I've already told you how to do. Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584206 Share on other sites More sharing options...
yans Posted February 2, 2021 Author Share Posted February 2, 2021 Hello Requinox. I still do not see when i enter to my website (in window url) grimlord/home automaticly maybe you see on www.gimlord.eu but I can't see of course I have all these beautiful links but it is not what i want. I showed you my friend what I need. On Clannad page for example. Maybe I can't cleary definite it. I will prepare short video from my point of view. Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584208 Share on other sites More sharing options...
yans Posted February 3, 2021 Author Share Posted February 3, 2021 (edited) 14 hours ago, requinix said: As far as I can tell, either you're asking how to do something you already know how to do, or you're asking how to do something I've already told you how to do. No I need Mod rewrite fumcion propably to do what i want (short adress instead long on my serwer) Edited February 3, 2021 by yans Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584214 Share on other sites More sharing options...
yans Posted February 5, 2021 Author Share Posted February 5, 2021 You can end this topic. I found solution at the moment. Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584238 Share on other sites More sharing options...
requinix Posted February 5, 2021 Share Posted February 5, 2021 I don't know what solution you found "at the moment", but a while ago I told you that you have to update the URLs you put onto your site to use the new forms, and that it will not happen automatically for you. For example, that means you have to replace every <a href="/index_pl.php?src=home"> with <a href="/home"> 1 Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584239 Share on other sites More sharing options...
yans Posted February 5, 2021 Author Share Posted February 5, 2021 (edited) 2 hours ago, requinix said: I don't know what solution you found "at the moment", but a while ago I told you that you have to update the URLs you put onto your site to use the new forms, and that it will not happen automatically for you. For example, that means you have to replace every <a href="/index_pl.php?src=home"> with <a href="/home"> Solution which allowed me going through further. Yes renamed adrees url in index.pl.php file, but I thought the code only changes in the file htaccess. RewriteRule ^start$ index_pl.php?src=home [L] This letler must be not [R] Now all is good in 90% because... I have trouble with Grimshop url link. It code has different location than all subpages. I found kind of location and I changed adreess but still not working grimlord.eu/grimshop and only ugly http://www.grimlord.eu/index_pl.php?src=shop it code for Grimshop Quote <a class="grimshop" href="http://www.grimlord.eu/grimshop" title=""><img src="img/logoshop.png" alt="GRIMSHOP - wejťcie do sklepu"></a></td> in htaccess like others RewriteEngine ON RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^start$ index_pl.php?src=home [L] RewriteRule ^grimshop$ index_pl.php?src=shop [L] Edited February 5, 2021 by yans Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584243 Share on other sites More sharing options...
requinix Posted February 5, 2021 Share Posted February 5, 2021 Whatever ecommerce thing you're using for that shop has to have its configuration updated so that it knows about the new URL. You're also going to discover that you need another RewriteRule flag. When that happens, check the mod_rewrite documentation for a flag dealing with query strings. Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584244 Share on other sites More sharing options...
yans Posted February 5, 2021 Author Share Posted February 5, 2021 Could you help me? I don't know anything about it. I changed some old ugly url on short in index.pl.php (in left bottom part of window appear good link when I hover over the grimshop logo) but higher still is ugly. Which flag? Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584245 Share on other sites More sharing options...
requinix Posted February 6, 2021 Share Posted February 6, 2021 I have no idea. It's your website, not mine. Quote Link to comment https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/#findComment-1584246 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.