: My website keeps redirect to the "index.php" account on Instagram app My htaccess code allows example.com/username redirect to any username on Instagram app. But when I open example.com it redirects
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=
More posts by @XinRu657
1 Comments
Sorted by latest first Latest Oldest Best
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=
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=
Or disable directory indexes altogether and redirect everything (change .+ to .*). For example:
DirectoryIndex disabled
RedirectMatch 302 /(.*) instagram://user?username=
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=
Or, you could even reduce it to something like example.com/i/<username> - if that is still unique.
RedirectMatch 302 /i/(.+) instagram://user?username=
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.