Hi guys, I hope I'm in the right place to receive some qualified answers. I have a website and I am trying to redirect my old files to new ones. I am using htaccess 301 redirect formula and I saw that I can redirect URLs like /myfolder/old-one to /myfolder/new-one , but I cannot redirect /myfolder/old-file.html to /myfolder/new-file.html I was reading online and saw that this could be a rewrite rude and/or condition issue, but as I am not a programmer I would be happy if I could get the help of professionals. Thanks in advance.
Hello, Here is all you need to know (and more) about 301 redirects: https://moz.com/learn/seo/redirection
thanks for this, but if someone could tell me the line of code for the case above would be even better, as I mentioned I'm not a programmer
You can redirect anything to anything, basically. The question becomes, what is the exact thing you're trying to do? Are you trying to redirect an old file (with its own filename) to a new file (with a new file name)? If that's the case, I think that it might be a complicated thing to do, if there's a lot of files. If it's just redirecting from /old_folder_structure/filename.html to /new_folder_structure/filename.html (different folders/path, but same filename) you can do that fairly easily. So, a little bit more information first would be nice. Is it the same domain? Just different paths? Different file names as well?
I will give you an answer without using a full URL as I need help not a ban : Redirect 301 /blog/blog-c45.html /en/the-common-room/blog-c45.html - this is in my htaccess file and is not redirecting Redirect 301 /en/new-products /en/new-courses - this is my htaccess file and is redirecting Same domain name. Thanks !
If you want to redirect all files to the same file in a new directory, just do something like this: Redirect 301 /blog/(.*) /en/the-common-room/blog/$1 Should work - although this: RewriteEngine on RewriteRule /blog/(.*) /en/the-common-room/blog/$1 [R=301,L] Might be better (although both should work)
Perhaps you have other rules in the .htaccess that overrides the one you're trying to add? Are you adding the .htaccess in the root folder?
I meant the root www folder. Adding anything further up the tree makes no sense. Could you perhaps post the whole htaccess file?
#START AS4 RULES (Do not remove) <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^as4_seositemap.xml$ modules/pm_advancedsearch4/seositemap.xml [L] RewriteCond %{QUERY_STRING} !^controller=products-comparison [NC] RewriteRule ^([a-z]{2})?/?s/([0-9]+)/([a-zA-Z0-9/_-]*) index.php?fc=module&module=pm_advancedsearch4&controller=advancedsearch4&isolang=$1&id_seo=$2&seo_url=$3 [QSA,L] RewriteCond %{QUERY_STRING} ^isolang=([a-z]{2})&id_seo=([0-9]+)&seo_url=([a-zA-Z0-9/_-]*).*p=([0-9]+)$ RewriteRule ^advancedsearch4.php /%1/s/%2/%3?p=%4 [R=301,L] RewriteCond %{QUERY_STRING} ^isolang=([a-z]{2})&id_seo=([0-9]+)&seo_url=([a-zA-Z0-9/_-]*) RewriteRule ^advancedsearch4.php /%1/s/%2/%3? [R=301,L] RewriteCond %{QUERY_STRING} ^id_seo=([0-9]+)&seo_url=([a-zA-Z0-9/_-]*).*p=([0-9]+)$ RewriteRule ^advancedsearch4.php /s/%1/%2?p=%3 [R=301,L] RewriteCond %{QUERY_STRING} ^id_seo=([0-9]+)&seo_url=([a-zA-Z0-9/_-]*) RewriteRule ^advancedsearch4.php /s/%1/%2? [R=301,L] </IfModule> #END AS4 RULES # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution <IfModule mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </IfModule> <IfModule mod_rewrite.c> <IfModule mod_env.c> SetEnv HTTP_MOD_REWRITE On </IfModule> # Disable Multiviews Options -Multiviews RewriteEngine on RewriteRule . - [E=REWRITEBASE:/] RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] # Images RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L] RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L] RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L] RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L] RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L] # AlphaImageLoader for IE and fancybox RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L] # Dispatcher RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L] </IfModule> AddType application/vnd.ms-fontobject .eot AddType font/ttf .ttf AddType font/otf .otf AddType application/x-font-woff .woff <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType text/css "access plus 1 week" ExpiresByType text/javascript "access plus 1 week" ExpiresByType application/javascript "access plus 1 week" ExpiresByType application/x-javascript "access plus 1 week" ExpiresByType image/x-icon "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType image/vnd.microsoft.icon "access plus 1 year" ExpiresByType application/font-woff "access plus 1 year" ExpiresByType application/x-font-woff "access plus 1 year" ExpiresByType application/vnd.ms-fontobject "access plus 1 year" ExpiresByType font/opentype "access plus 1 year" ExpiresByType font/ttf "access plus 1 year" ExpiresByType font/otf "access plus 1 year" ExpiresByType application/x-font-ttf "access plus 1 year" ExpiresByType application/x-font-otf "access plus 1 year" </IfModule> FileETag INode MTime Size <IfModule mod_deflate.c> <IfModule mod_filter.c> AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript </IfModule> </IfModule> Redirect 301 /blog/(.*) /en/the-common-room/$1 Redirect 301 /en/new-products /en/new-courses Redirect 301 /en/module/blockwishlist/mywishlist /en/planner Redirect 301 /module/advancefaqs/AdvanceTopics /en/module/advancefaqs/AdvanceTopics Redirect 301 /en/blog.html /en/the-common-room.html Redirect 301 /en/blog/10-things-students-wish-they-knew-in-first-year-uni-b158.html /en/the-common-room/10-things-students-wish-they-knew-in-first-year-uni-b158.html Redirect 301 /en/blog/10-university-societies-you-wish-you-were-joining-this-september-b140.html /en/the-common-room/10-university-societies-you-wish-you-were-joining-this-september-b140.html Redirect 301 /en/blog/25-things-every-student-realises-in-freshers-week-b139.html /en/the-common-room/25-things-every-student-realises-in-freshers-week-b139.html Redirect 301 /en/blog/6-reasons-why-getting-a-job-at-sixth-form-is-a-great-idea-b155.html /en/the-common-room/6-reasons-why-getting-a-job-at-sixth-form-is-a-great-idea-b155.html Redirect 301 /en/blog/7-ways-to-increase-your-employability-at-uni-b157.html /en/the-common-room/7-ways-to-increase-your-employability-at-uni-b157.html Redirect 301 /en/blog/8-money-saving-tips-for-uni-life-b154.html /en/the-common-room/8-money-saving-tips-for-uni-life-b154.html Redirect 301 /en/blog/8-revision-hacks-to-help-you-survive-year-13-exams-b156.html /en/the-common-room/8-revision-hacks-to-help-you-survive-year-13-exams-b156.html Redirect 301 /en/blog/advice-guidance-c48.html /en/the-common-room/advice-guidance-c48.html Redirect 301 /en/blog/applying-to-study-in-uk-b113.html /en/the-common-room/applying-to-study-in-uk-b113.html Redirect 301 /en/blog/blog-c45.html /en/the-common-room/blog-c45.html Redirect 301 /en/blog/choosing-a-course-b110.html /en/the-common-room/choosing-a-course-b110.html Redirect 301 /en/blog/choosing-a-university-c59.html /en/the-common-room/choosing-a-university-c59.html Redirect 301 /en/blog/documents-c53.html /en/the-common-room/documents-c53.html Redirect 301 /en/blog/english-language-tests--b145.html /en/the-common-room/english-language-tests--b145.html Redirect 301 /en/blog/find-a-course-c49.html /en/the-common-room/find-a-course-c49.html Redirect 301 /en/blog/find-a-course-c50.html /en/the-common-room/find-a-course-c50.html Redirect 301 /en/blog/funding-b151.html /en/the-common-room/funding-b151.html Redirect 301 /en/blog/funding-c54.html /en/the-common-room/funding-c54.html Redirect 301 /en/blog/funding-c62.html /en/the-common-room/funding-c62.html Redirect 301 /en/blog/further-plans-c55.html /en/the-common-room/further-plans-c55.html Redirect 301 /en/blog/how-to-choose-a-course-in-the-uk-b109.html /en/the-common-room/how-to-choose-a-course-in-the-uk-b109.html Redirect 301 /en/blog/how-to-choose-the-best-study-location-in-the-uk-b110.html /en/the-common-room/how-to-choose-the-best-study-location-in-the-uk-b110.html Redirect 301 /en/blog/how-to-choose-the-right-university-b142.html /en/the-common-room/how-to-choose-the-right-university-b142.html Redirect 301 /en/blog/how-to-find-a-graduate-career-in-the-uk-b124.html /en/the-common-room/how-to-find-a-graduate-career-in-the-uk-b124.html Redirect 301 /en/blog/how-to-find-a-part-time-job-while-studying-in-the-uk-b123.html /en/the-common-room/how-to-find-a-part-time-job-while-studying-in-the-uk-b123.html Redirect 301 /en/blog/how-to-find-the-ideal-student-accommodation-for-you-b111.html /en/the-common-room/how-to-find-the-ideal-student-accommodation-for-you-b111.html Redirect 301 /en/blog/how-to-get-a-recommendation-letter-when-applying-for-a-uni-b119.html /en/the-common-room/how-to-get-a-recommendation-letter-when-applying-for-a-uni-b119.html Redirect 301 /en/blog/how-to-get-a-scholarship-to-study-in-the-uk-b120.html /en/the-common-room/how-to-get-a-scholarship-to-study-in-the-uk-b120.html Redirect 301 /en/blog/how-to-get-educational-loan-to-study-in-the-uk-b121.html /en/the-common-room/how-to-get-educational-loan-to-study-in-the-uk-b121.html Redirect 301 /en/blog/how-to-get-educational-loan-to-study-in-the-uk-b122.html /en/the-common-room/how-to-get-educational-loan-to-study-in-the-uk-b122.html Redirect 301 /en/blog/how-to-prepare-for-your-gre-gmat-test-b117.html /en/the-common-room/how-to-prepare-for-your-gre-gmat-test-b117.html Redirect 301 /en/blog/how-to-write-a-personal-statement--b147.html /en/the-common-room/how-to-write-a-personal-statement--b147.html Redirect 301 /en/blog/life-in-the-uk-c61.html /en/the-common-room/life-in-the-uk-c61.html Redirect 301 /en/blog/living-in-the-uk-b152.html /en/the-common-room/living-in-the-uk-b152.html Redirect 301 /en/blog/planning-c49.html /en/the-common-room/planning-c49.html Redirect 301 /en/blog/reference-guidance-b146.html /en/the-common-room/reference-guidance-b146.html Redirect 301 /en/blog/sixth-form-c63.html /en/the-common-room/sixth-form-c63.html Redirect 301 /en/blog/student-accommodation--b148.html /en/the-common-room/student-accommodation--b148.html Redirect 301 /en/blog/student-visas-b149.html /en/the-common-room/student-visas-b149.html Redirect 301 /en/blog/test-prep-c52.html /en/the-common-room/test-prep-c52.html Redirect 301 /en/blog/types-of-courses-b144.html /en/the-common-room/types-of-courses-b144.html Redirect 301 /en/blog/types-of-degree-c60.html /en/the-common-room/types-of-degree-c60.html Redirect 301 /en/blog/university-life-c57.html /en/the-common-room/university-life-c57.html Redirect 301 /en/blog/visas-c51.html /en/the-common-room/visas-c51.html Redirect 301 /en/blog/why-study-in-the-uk-b150.html /en/the-common-room/why-study-in-the-uk-b150.html Redirect 301 /en/blog/why-study-in-the-uk-c58.html /en/the-common-room/why-study-in-the-uk-c58.html Redirect 301 /en/blog/how-to-write-a-personal-statement--b147.html /en/the-common-room/how-to-write-a-personal-statement--b147.html Redirect 301 /en/blog/life-in-the-uk-c61.html /en/the-common-room/life-in-the-uk-c61.html Redirect 301 /en/blog/living-in-the-uk-b152.html /en/the-common-room/living-in-the-uk-b152.html Redirect 301 /en/blog/planning-c49.html /en/the-common-room/planning-c49.html Redirect 301 /en/blog/reference-guidance-b146.html /en/the-common-room/reference-guidance-b146.html Redirect 301 /en/blog/sixth-form-c63.html /en/the-common-room/sixth-form-c63.html Redirect 301 /en/blog/student-accommodation--b148.html /en/the-common-room/student-accommodation--b148.html Redirect 301 /en/blog/student-visas-b149.html /en/the-common-room/student-visas-b149.html Redirect 301 /en/blog/test-prep-c52.html /en/the-common-room/test-prep-c52.html Redirect 301 /en/blog/types-of-courses-b144.html /en/the-common-room/types-of-courses-b144.html Redirect 301 /en/blog/types-of-degree-c60.html /en/the-common-room/types-of-degree-c60.html Redirect 301 /en/blog/university-life-c57.html /en/the-common-room/university-life-c57.html Redirect 301 /en/blog/visas-c51.html /en/the-common-room/visas-c51.html Redirect 301 /en/blog/why-study-in-the-uk-b150.html /en/the-common-room/why-study-in-the-uk-b150.html Redirect 301 /en/blog/why-study-in-the-uk-c58.html /en/the-common-room/why-study-in-the-uk-c58.html Redirect 301 /en/blog/how-to-choose-the-best-study-location-in-the-uk-b110.html /en/the-common-room/how-to-choose-the-best-study-location-in-the-uk-b110.html Redirect 301 /en/blog/how-to-choose-the-right-university-b142.html /en/the-common-room/how-to-choose-the-right-university-b142.html Redirect 301 /en/new-products /en/new-courses Redirect 301 /en/module/blockwishlist/mywishlist /en/planner Redirect 301 /module/advancefaqs/AdvanceTopics #If rewrite mod isn't enabled ErrorDocument 404 /index.php?controller=404 # ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
I have posted the code. I saw the htaccess on the ftp in two places uploaded , one is a root folder and the other var/www one. Just one instance right ?