I am attempting to use .htaccess to redirect a single page in expression engine to another site's page. Our .htaccess file has a ton of other rewrite rules and rewrite conditions to ensure the expression engine site runs effectively.
I have this RedirectMatch at the top of the .htaccess file.
RedirectMatch (?i)^/my-page The redirect is sending to the new site okay except for it's adding an extra '?/my-page' at the end of my url on the target server. So it is coming through as ""
I believe this is because of some other rules below this one in the .htaccess files appending/attempting to some extra parts of URLs.
How I ensure that only the first line is executed using .htaccess?
Also, is there a way I can test what exactly the .htaccess URL is trying to send before it goes, through some type of access/log file?
Thanks!
2 Answers
Try to add [L] flag at the end of the line. Think, might help.
RedirectMatch (?i)^/my-page [L]More about flags in .htaccess here
@atom_n was correct that I needed a L flag!
However, the L flag does not work for RedirectMatch so I had to use a rewrite rule. The final working solution is below
RewriteCond %{REQUEST_URI} /my-page [NC]
RewriteRule (.*) [R=301,L]It worked perfectly after that.