Jump to content

Recommended Posts

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]

Link to comment
https://forums.phpfreaks.com/topic/312067-i-would-like-nice-url-link-how-change/
Share on other sites

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

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.

  • Thanks 1


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 example
https://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.

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.

  • Thanks 1
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

 

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.

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   

live.jpg

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.

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 by yans

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">

 

  • Great Answer 1
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 by yans

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.