trying to redirect Via htaccess


Recommended Posts

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

I found the htaccess code after browsing in internet

redirectMatch 301 ^/Iklan/(.+)$

But it redirect url marked as 410 to  (it creates two redirect , 301 and then 410)

And some of them are 404 ( the url above is just sample, theres hundreds of them) 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?


Link to comment
Share on other sites

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


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.

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.