My website keeps redirect to the "index.php" account on Instagram app

My website keeps redirect to the "index.php" account on Instagram app - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the My website keeps redirect to the "index.php" account on Instagram app error on your web browser. Problem :


My htaccess code allows example.com/username redirect to any username on Instagram app. But when I open example.com it redirects to an Instagram account called index.php.
How can I fix it?
Here is my htaccess



RedirectMatch 302 /(.+) instagram://user?username=$1

Solution :

This is probably due to mod_dir issuing a subrequest for the directory index (ie. index.php).



You can try adding a negative lookahead to the regex to specifically exclude requests for index.php. For example:



RedirectMatch 302 /(?!index.php)(.+) instagram://user?username=$1


UPDATE: If you are now having a problem with index.html (another possible directory index) then you can exclude this as well:



RedirectMatch 302 /(?!index.php|index.html)(.+) instagram://user?username=$1


Or disable directory indexes altogether and redirect everything (change .+ to .*). For example:



DirectoryIndex disabled
RedirectMatch 302 /(.*) instagram://user?username=$1


However, this will redirect even when no username is given.






To avoid conflicts with your existing site, it would probably be preferable to make this "instagram" URL unique, so it doesn't override your existing URLs. For example: example.com/instagram/<username>. You could then simplify the above directive to:



RedirectMatch 302 /instagram/(.+) instagram://user?username=$1


Or, you could even reduce it to something like example.com/i/<username> - if that is still unique.



RedirectMatch 302 /i/(.+) instagram://user?username=$1

We hope that this article has helped you resolve the htaccess, redirects, deeplinks error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=