trying to redirect Via htaccess


berko

Recommended Posts

Im trying to redirect 301 hundreds of error url under some category to my homepage except certain url to 410 Gone

domain.com/Iklan/3262                                                        >>>> should be 301

domain.com/Iklan/3264                                                        >>>> should be 301

domain.com/Iklan/3265/?fb_comment_id=788343724   >>>redirect 410

domain.com/Iklan/3267??attachment_id=1082                >>>redirect 410

I found the htaccess code after browsing in internet

redirectMatch 301 ^/Iklan/(.+)$ https://domain.com/

But it redirect url marked as 410 to domain.com/?attachment_id=1082  (it creates two redirect , 301 and then 410)

And some of them are 404 ( the url above is just sample, theres hundreds of them)..im suspecting there's upper case or different char but im not sure

I have weak eyes and i cant tell which on of the letter is using upper case

Can anyone help me?

Thanks

Link to comment
Share on other sites

On 9/30/2019 at 8:24 AM, berko said:

^/Iklan/(.+)$ https://domain.com/

Your regular expression (above) matches the following:

^ -> means the start of the target, so the matches will have nothing before /iklan/. Something like /abc/iklan/ will not match.
( ) is for grouping, but that is not used here, so those are redundant
.+ -> means one or more of any character
$ -> means the end

In summary, this will match anything starting with /iklan/ followed by one or more characters.

It would appear that it is redirecting the URLs (the part before the ?'s) and preserving the query strings (the ? and what comes after).
That accounts for the 301's.
The 410's must arise from some other rule.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...