March 9, 201115 yr Hi, I recently moved my website to another domain name and although i have set up a redirect to send all traffic from the old .com address to the new .co.uk address, it brings up a blank RSS feed if anyone is still using the feed from the old .com address. What i would like to do, is to set up a 301 redirect from the old non-functioning .com feed URL to the new, working .co.uk feed URL. I've looked into it and have found some 301 code for an .htaccess file (which would be my preffered method) but i can't get it to work properly. I'm probably using it all wrong. My current code looks like this: # RSS Feed Redirect # Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^feed://www.voltronik.com/feed/$ RewriteRule ^(.*)$ feed://www.voltronik.co.uk/feed/$1 [R=301,L] and i want to redirect this feed URL: feed://www.voltronik.com/feed/ to this feed URL: feed://www.voltronik.co.uk/feed/ Any help would be much appreciated! Many thanks, -Jack
March 9, 201115 yr A RewriteRule matches whole paths, and not hosts or protocols (which can be matched by the appropriate RewriteCond but not doing the scheme and host in one go, as you have done). You therefore need something like: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.voltronik.com$ RewriteRule ^/feed/(.*)$ feed://www.voltronik.co.uk/feed/$1 [R=301,L] Does that work for you? Edited March 9, 201115 yr by Connetu_C
March 9, 201115 yr Hi, I recently moved my website to another domain name and although i have set up a redirect to send all traffic from the old .com address to the new .co.uk address, it brings up a blank RSS feed if anyone is still using the feed from the old .com address. What i would like to do, is to set up a 301 redirect from the old non-functioning .com feed URL to the new, working .co.uk feed URL. I've looked into it and have found some 301 code for an .htaccess file (which would be my preffered method) but i can't get it to work properly. I'm probably using it all wrong. My current code looks like this: # RSS Feed Redirect # Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^feed://www.voltronik.com/feed/$ RewriteRule ^(.*)$ feed://www.voltronik.co.uk/feed/$1 [R=301,L] and i want to redirect this feed URL: feed://www.voltronik.com/feed/ to this feed URL: feed://www.voltronik.co.uk/feed/ Any help would be much appreciated! Many thanks, -Jack mmm why not just do an html redirect, or a php redirect? HTML WAY <meta HTTP-EQUIV="REFRESH" content="0; url=www.newurl.com"> PHP WAY header("Location:www.newurl.com");
March 9, 201115 yr mmm why not just do an html redirect, or a php redirect? HTML WAY <meta HTTP-EQUIV="REFRESH" content="0; url=www.newurl.com"> PHP WAY header("Location:www.newurl.com"); Client side redirects (using HTML) should be avoided for two reasons: (1) they rely on the client to understand the HTML in order to do the redirect; (2) they involve serving an unnecessary amount of header and body data in the HTTP response. An HTTP redirect response is better - either by server-side header manipulation in scripts (e.g. in PHP) or by server configuration... it doesn't really matter. Of course, if you're serving a resource from a static file, the script method doesn't apply and you are forced to use server configuration (which in my opinion is a "cleaner" solution in many cases anyway, particularly if a resource has moved).
March 10, 201115 yr Author A RewriteRule matches whole paths, and not hosts or protocols (which can be matched by the appropriate RewriteCond but not doing the scheme and host in one go, as you have done). You therefore need something like: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.voltronik.com$ RewriteRule ^/feed/(.*)$ feed://www.voltronik.co.uk/feed/$1 [R=301,L] Does that work for you? Thanks for the code and the input but unfortunately not. If you go to feed://www.voltronik.com/feed/ then it's still just blank. -Jack
March 10, 201115 yr Thanks for the code and the input but unfortunately not. If you go to feed://www.voltronik.com/feed/ then it's still just blank. Where are you putting the .htaccess file? In what directory/path?
March 10, 201115 yr Author Where are you putting the .htaccess file? In what directory/path? It's at voltronik.co.uk/.htaccess -Jack
March 10, 201115 yr I forgot that if you put the rewrite in .htaccess in a directory, rather than in the server config file, you don't put the leading directory path on paths - in your case this is just the /. So you need: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.voltronik.com$ RewriteRule ^feed/(.*)$ feed://www.voltronik.co.uk/feed/$1 [R=301,L] Does that work now?
March 10, 201115 yr Author I forgot that if you put the rewrite in .htaccess in a directory, rather than in the server config file, you don't put the leading directory path on paths - in your case this is just the /. So you need: RewriteEngine on RewriteCond %{HTTP_HOST} ^www.voltronik.com$ RewriteRule ^feed/(.*)$ feed://www.voltronik.co.uk/feed/$1 [R=301,L] Does that work now? Unfortunately not. I get nothing in Safari but Firefox shows this: Not Found The requested URL /feed/ was not found on this server. Additionally, a 404 Not Founderror was encountered while trying to use an ErrorDocument to handle the request. -Jack
March 10, 201115 yr It worked for me on a test server (using a different domain obviously), so I don't think there's anything wrong with the .htaccess snippet I supplied above. You should check your server error logs (if you have access to them) as they may hint as to why it's not working. Other things to check are the main server configuration - is mod_rewrite enabled and does the config allow you to use these directives in .htaccess files? Does your Web server have permissions to read the .htaccess file - e.g. are any other directives working (permission errors should also be shown in your error logs)? Are you using any other rewrite directives (explicitly or implicitly, for example provided by a CMS) which may conflict?
March 10, 201115 yr Author It worked for me on a test server (using a different domain obviously), so I don't think there's anything wrong with the .htaccess snippet I supplied above. You should check your server error logs (if you have access to them) as they may hint as to why it's not working. Other things to check are the main server configuration - is mod_rewrite enabled and does the config allow you to use these directives in .htaccess files? Does your Web server have permissions to read the .htaccess file - e.g. are any other directives working (permission errors should also be shown in your error logs)? Are you using any other rewrite directives (explicitly or implicitly, for example provided by a CMS) which may conflict? As far as i know it should just work. I use my .htaccess file for a few things. Here it is in it's entirety (including your bit at the bottom): # Support for Web Fonts AddType application/vnd.ms-fontobject .eot AddType font/ttf .ttf AddType font/otf .otf AddType “application/x-woff” .woff AddType image/svg+xml svg svgz # Support for Web Fonts # Support for Caching Expiries <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/gif "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType text/css "access 1 month" ExpiresByType application/pdf "access 1 month" ExpiresByType image/x-icon "access 1 year" ExpiresDefault "access 2 days" </IfModule> # Support for Caching Expiries # Support for Gzip <IfModule mod_deflate.c> # these are known to be safe with MSIE 6 AddOutputFilterByType DEFLATE text/html text/plain text/xml # everything else may cause problems with MSIE 6 AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE application/vnd.ms-fontobject .eot </IfModule> # Support for Gzip # BEGIN WPSuperCache <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / AddDefaultCharset UTF-8 RewriteCond %{REQUEST_URI} !^.*[^/]$ RewriteCond %{REQUEST_URI} !^.*//.*$ RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{QUERY_STRING} !.*=.* RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$ RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC] RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).* [NC] RewriteCond %{HTTP:Accept-Encoding} gzip RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f RewriteRule ^(.*) "/blog/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz" [L] RewriteCond %{REQUEST_URI} !^.*[^/]$ RewriteCond %{REQUEST_URI} !^.*//.*$ RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{QUERY_STRING} !.*=.* RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$ RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).* [NC] RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).* [NC] RewriteCond %{DOCUMENT_ROOT}/blog/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f RewriteRule ^(.*) "/blog/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html" [L] </IfModule> # END WPSuperCache RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://voltronik.co.uk/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://voltronik.co.uk$ [NC] RewriteCond %{HTTP_REFERER} !^http://voltronik.voltronik.co.uk/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://voltronik.voltronik.co.uk$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.voltronik.co.uk/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.voltronik.co.uk$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.voltronik.voltronik.co.uk/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.voltronik.voltronik.co.uk$ [NC] RewriteRule .*\.(jpg|jpeg|gif|png|bmp|ico)$ - [F,NC] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress # RSS Feed Redirect RewriteEngine on RewriteCond %{HTTP_HOST} ^www.voltronik.com$ RewriteRule ^/feed/(.*)$ feed://www.voltronik.co.uk/feed/$1 [R=301,L] # RSS Feed Redirect
March 10, 201115 yr It isn't working because of a conflict with your Wordpress rewrites. You could work out exactly where this is happening and put some exclusions in, or you could just move the code fragment we wrote to place it before every other Wordpress rewrite (possibly in the server configuration itself if there are any rewrites in there), so it gets done first. What is likely happening is that another rule is executing with an [L] and therefore the "Feed Redirect" block is never even processed.
March 10, 201115 yr Author It isn't working because of a conflict with your Wordpress rewrites. You could work out exactly where this is happening and put some exclusions in, or you could just move the code fragment we wrote to place it before every other Wordpress rewrite (possibly in the server configuration itself if there are any rewrites in there), so it gets done first. What is likely happening is that another rule is executing with an [L] and therefore the "Feed Redirect" block is never even processed. Just placed it under my font bit and it still doesn't work. Gosh this is troublesome! Thanks for all your input so far. Would love to get it sorted but not sure how much more i can do :S
March 10, 201115 yr Just placed it under my font bit and it still doesn't work. Gosh this is troublesome! Thanks for all your input so far. Would love to get it sorted but not sure how much more i can do :S Can you try the code on another system without Wordpress installed (even a local Apache install on your workstation)? At least you'll know whether it's the rewrite itself or something else in Wordpress conflicting. You could also do a blanket redirect from .com to .co.uk - this is beneficial for SEO besides (as some search engines penalise "duplicate content" on different domains). If that worked as the first rule in the script, then your feed would also redirect. Not sure how you do this with the feed:// protocol - might need another RewriteCond to catch this case.
March 10, 201115 yr Author Can you try the code on another system without Wordpress installed (even a local Apache install on your workstation)? At least you'll know whether it's the rewrite itself or something else in Wordpress conflicting. You could also do a blanket redirect from .com to .co.uk - this is beneficial for SEO besides (as some search engines penalise "duplicate content" on different domains). If that worked as the first rule in the script, then your feed would also redirect. Not sure how you do this with the feed:// protocol - might need another RewriteCond to catch this case. I currently have a redirect from the .com to the .co.uk set up in the cPanel at my host. Maybe i could try this there instead?
Create an account or sign in to comment