I
I
Igor2017-03-14 16:18:44
MODX
Igor, 2017-03-14 16:18:44

How can you defeat such broken links?

Hello
It suddenly turned out that on the site (modx) broken links like
http:/www.site.ru/db.php?j=61&q=689&c=5
http:/www.site.ru/db.php? j=67&s=55&c=5
http:/www.site.ru/db.php?j=45&q=9691&c=5
..
The reason is db.php is a self-written crutch that forms the database of visitors and customers for the site by ip.
Why, xs.
Is it possible to defeat such a disgrace with a redirect?
For example, by making a redirect from these links to www.site.ru.

RewriteRule ^db.php?(.*)$ http://www.site.ru [L,R=301]
(that's correct, by the way?)
Or is such a solution to dealing with broken links fundamentally wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2017-03-14
@shambler81

no, everything after the question is GET
you need "how to make a redirect with a get parameter"
Or like this

# 301 --- http://site.ru/cat1/cat2/art.htm?fb_comment_id=12345&start=2  => http://site.ru/cat1/cat2/article.html?start=2
RewriteCond %{QUERY_STRING} (^|&)fb_comment_id\=12345($|&)
RewriteCond %{QUERY_STRING} (^|&)start\=2 ($|&)
RewriteRule ^cat1/cat2/art\.htm$ /cat1/cat2/article.html?start=2 [L,R=301]

I
Igor, 2017-03-15
@onedeadyankee

no, everything after the question is GET
you need "how to make a redirect with a get parameter"

thanks, I googled about get parameters
If anyone is interested, then the working version for links like http:/www.site.ru/db.php?j=45&q=9691&c=5 turned out like this
RewriteCond %{QUERY_STRING} j=(\d+) [NC]
RewriteCond %{QUERY_STRING} q=(\d+) [NC]
RewriteRule .* http://www.site.ru/? [R=301,L]
RewriteRule ^db.php$ http://www.site.ru [L,R=301]

Checking if "j" is equal to any number, then "q". for "c" there is no point in doing it, I have it permanent, correct me if I misunderstood the principle?
Well, then just a redirect from db.php just in case

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question