How to remove the key from the URL?

Hi.

There is a link: gdz2/index.php?id=2

You need to remove keys "?id=2"

It is desirable that-the URL looked like this: gdz2/index

I think this can be done using .htaccess, but have no idea how to do it...
Thanks in advance!
April 19th 20 at 12:34
1 answer
April 19th 20 at 12:36
Solution
RewriteCond %{QUERY_STRING} (^|&)id\=2($|&)
RewriteRule ^gdz2/index\.php$ /gdz2/index? [L,R=301]
Not working...
Here is the file:


DirectoryIndex main.php
RewriteCond %{QUERY_STRING} (^|&)id\=2($|&)
RewriteRule ^gdz2/index\.php$ /gdz2/index? [L,R=301]
- marcel commented on April 19th 20 at 12:39
@marcel, can not work
the whole file let's - Hannah19 commented on April 19th 20 at 12:42
@Hannah19,
<IfModule dir_module>
 DirectoryIndex main.php
 RewriteCond %{QUERY_STRING} (^|&)id\=2($|&)
 RewriteRule ^gdz2/index\.php$ /gdz2/index? [L,R=301]
</IfModule>
- marcel commented on April 19th 20 at 12:45
@marcel, RewriteEngine on , excuse me where ? - Hannah19 commented on April 19th 20 at 12:48
@Hannah19Added, seravno not working...
<IfModule dir_module>
 DirectoryIndex main.php
 RewriteEngine on
 RewriteCond %{QUERY_STRING} (^|&)id\=2($|&)
 RewriteRule ^gdz2/index\.php$ /gdz2/index? [L,R=301]
</IfModule>
- marcel commented on April 19th 20 at 12:51
give the full url it was - Hannah19 commented on April 19th 20 at 12:54
@Hannah19, gdz2/index.php?id=2 here is the url, nothing changes - marcel commented on April 19th 20 at 12:57
gdz2 is the domain? - Hannah19 commented on April 19th 20 at 13:00

DirectoryIndex main.php
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)id\=2($|&)
RewriteRule ^index\.php$ /index? [L,R=301]
- Hannah19 commented on April 19th 20 at 13:03
@Hannah19, gdz2 is a folder with the site on the local server - marcel commented on April 19th 20 at 13:06
@Hannah19, gdz2/index so now it looks address...
But instead of the page that we see such a thing:
5e9ad87b76e85934835162.png - marcel commented on April 19th 20 at 13:09
@marcel, all right
redirect does not create files in the place where they are not. - Hannah19 commented on April 19th 20 at 13:12
@Hannah19Never worked with htaccess :( Explain how to fix it please. - marcel commented on April 19th 20 at 13:15
you have a very strange desire to make redirect index without PHP.
I can assume that the CNC have either.
Moved the redirect request to this index, the question is as he is?
the answer is no
For this, he tried to find /index/index.php
but also no.
So what to run? - Hannah19 commented on April 19th 20 at 13:18
@Hannah19, I googled what is CNC, and it looks like this is what I need! Advise article or any other source of information on setting it up please because I haven't found anything... - marcel commented on April 19th 20 at 13:21
I will advise you even more
all the programmers at the beginning of trying to write your own engine, that's fine.
But I don't think you're trying to write a unique code, most likely it is implemented on existing platforms
Really makes sense to write campisi
if you have 3000 lines of code in all
or 10 Million budget at least.
Everything else will fit in DIAC, take Bitrix and so on the tops of their uralla and use them.
There is already CNC. - Hannah19 commented on April 19th 20 at 13:24
@Hannah19, I'll tell you honestly, for me it does not make sense to do the website on the engine, since programming is my hobby :) The main for me is the experience I will receive at the time of development of this site, and will be able to apply it in the future... And at my age I have plenty of time, so for me it's not a problem)

Now I'll pick some engines, it became interesting :3 - marcel commented on April 19th 20 at 13:27

Find more questions by tags Processing URLhtaccess