: Redirect multiple files using .htaccess I have a lot of files with a lot of sub directories which I moved one folder up, so, say, instead of example.com/cdn/folder/folder/file.html, it now looks
I have a lot of files with a lot of sub directories which I moved one folder up, so, say, instead of example.com/cdn/folder/folder/file.html, it now looks like this example.com/folder/folder/file.html.
My problem lies in SEO, I have a lot of back links which point to files which used to be in the old directory structure, and everyone who tries to access these files via those links will get a 404.
Now, I know that I can resolve the problem by adding a simple line of code in .htaccess, so I have read quite a number of tutorials on the Internet which explain how to redirect files from one place to another using wildcards and RedirectMatch techniques. I have found a site which explains how to do it, but I can't seem to get it working. I don't know what my problem is.
This is what I have come up with so far:
RedirectMatch 301 /cdn/folder/folder/(.*)/(.*) example.com/folder/folder//
This, however, does not do what I want it to do. Say, if someone accesses a file via example.com/cdn/folder/folder/file.html, they will get a 404. The code above does not resolve the problem. But, it does what I want it to do only for example.com/cdn/folder. Someone trying to access the subdirectory of /cdn will be redirected to /folder.
Please point me in the right direction.
More posts by @Connie744
1 Comments
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.