Reputation: 515
We have a folder 'userupload' under root directory which consist of subfolder and user uploaded images. Now, Considering to move 'userupload' folder to images/userupload
However, how to let search engines know that a redirect has happpened
site.com/userupload
to
site.com/images/userupload
Is there any way that this can be executed through htaccess so that search engines can be redirected that the folder'userupload' and all subfolders with userupload and images has moved to images/userupload folder
Am slight afraid as my colleage has told that making a wrong redirect can lead to infinite loop. . I dont have a code to mention which have tried as really dont know how to perform it. Can some one help on it
Many thanks
Upvotes: 0
Views: 43
Reputation: 143906
You can add these rules to your htaccess file in your document root.
Redirect 301 /userupload /images/userupload
Simple as that. It would be a lot trickier if the redirect was the other way around or if it was a redirect into the same folder, as that could cause redirect loops. But this one is pretty straightforward.
If you have mod_rewrite rules that rewrite stuff related to the /userupload/
directory, you may want to consider sticking with mod_rewrite instead of using a mod_alias directive (i.e. Redirect
):
RewriteRule ^userupload/(.*)$ /images/userupload/$1 [L,R=301]
You should add that before any other rewrite rules in your htaccess file.
Upvotes: 1