bigfuz Posted June 9, 2009 Share Posted June 9, 2009 For years I had a "redirect" from the main home page (i.e. www.website.com/index.htm) to my blog home page (www.website.com/blog/index.htm), and it worked great...everything was transparent, and when you went to my site (i.e. website.com) you immediately got my blog (website.com/blog) A few weeks ago it stopped working, and I have since had to make my homepage redirect through HTML (i.e. a META tag Refresh). This works, but it is not transparent, and takes a second to switch over. Any ideas why the redirects ain't working anymore? I was wondering if they are now considered "unsafe" so web browsers are not allowing it? (i.e. maybe it stopped working on the latest update or release of Firefox/IE?) Anyone else see similar? Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted June 9, 2009 Share Posted June 9, 2009 I use redirects and they are instantaneous. If you are having an issue please open a ticket with the help desk and have one of the techs take a look. Quote Link to comment Share on other sites More sharing options...
bigfuz Posted June 9, 2009 Author Share Posted June 9, 2009 I use redirects and they are instantaneous. If you are having an issue please open a ticket with the help desk and have one of the techs take a look. OK thanks, I submitted a ticket. Quote Link to comment Share on other sites More sharing options...
bigfuz Posted June 9, 2009 Author Share Posted June 9, 2009 Ends up there is a Cpanel issue (maybe a latest version) in redirecting the root domain to a subdirectory of that domain. Here is a link to the CPanel Forum post about it, and what is recommended fixes the issue: http://forums.cpanel.net/f4/redirect-subdirectory-24627.html Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted June 9, 2009 Share Posted June 9, 2009 I would just mod the .htaccess file manually if that's the case. Do you have other content on your site? If not, why not move your blog to the root folder? Quote Link to comment Share on other sites More sharing options...
mycat2 Posted June 21, 2009 Share Posted June 21, 2009 I have the same issue and I prefer not to put my blog in the root directory so I need to modify the .htaccess file - I looked at the comments in the link provided above and they say to to this : example: RewriteEngine on RewriteCond %{HTTP_HOST} index.html RewriteRule ^.*$ "http\:\/\/www\.TrueChange\.net\/main\/" [R=301,L] However my RewriteCond is a bit different: RewriteCond %{HTTP_HOST} ^mywebsite.com$ [OR] RewriteCond %{HTTP_HOST} ^www.mywebsite.com$ so is the RewriteRule the same as what they list above: RewriteRule ^.*$ "http\:\/\/www\.myblog\.com\/main\/" [R=301,L] or should it be different since I have the with or without www thing... I'm not a tech so I'm not sure what it should and should not say. thanks. Quote Link to comment Share on other sites More sharing options...
SteveW Posted June 22, 2009 Share Posted June 22, 2009 I would change your two Cond lines to this one line, which accomplishes the same thing. (www\.)? means with or without "www.". This also specifies that case is not significant [NC], and adds required backslashes because this is a regular expression: RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com$ [NC] This line should not have the backslashes because it is not a regular expression. RewriteRule ^.*$ "http\:\/\/www\.myblog\.com\/main\/" [R=301,L] It should be this (except that you need to change hxxp to http): RewriteRule ^.*$ hxxp://www.myblog.com/main/ [R=301,L] Together they would be: RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com$ [NC] RewriteRule ^.*$ hxxp://www.myblog.com/main/ [R=301,L] Although this fixes technical errors, it still might not accomplish what you want. Regardless of what page was requested, it will redirect all requests to the (same) single page at /main/. It makes no provision for choosing among different pages within /main/ based on what page was originally requested. Quote Link to comment Share on other sites More sharing options...
mycat2 Posted June 23, 2009 Share Posted June 23, 2009 (edited) Thanks, but darn, I just realized something while reading your reply, where I said I was redirectling to is incorrect, the blog that I want to redirect to is in a subdirectory - I want to redirect to www.mysite.com/myblog. So would it be correct to say: RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com$ [NC] RewriteRule ^.*$ hxxp://www.mysite.com/myblog/ [R=301,L] I don't understand why they made this change to the cpanel - it was so easy to do before! Edited June 23, 2009 by TCH-Bruce romoved extra quoting Quote Link to comment Share on other sites More sharing options...
SteveW Posted June 23, 2009 Share Posted June 23, 2009 (edited) Yes, that looks right, except for one important thing I missed before: it will create an infinite loop. I'll consider that last. First, here's some other info... Here's a way you can test rewrites only on yourself, without affecting other site visitors. Change the 111.222.333.444 to your IP address: RewriteCond %{REMOTE_ADDR} ^111\.222\.333\.444$ RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com$ [NC] RewriteRule ^.*$ hxxp://www.mywebsite.com/myblog/ [R=301,L] Is it ok that it always redirects to the same page regardless of what the original request was? In other words, no matter what page a visitor requests in mywebsite.com, they will always be sent to your blog's home page. It will be impossible for them to go directly to any page other than your blog's home page. If that's not ok, we can try to deal with that later. The second problem is that the new, redirected, request also goes to mywebsite.com, so it will invoke the rewrite rule again, and again, in an infinite loop. The server imposes a limit of 20 redirects, so eventually it will stop and no page will be served. A serious problem, obviously. We need to prevent the redirect when the page requested is already in /myblog/. I think this might do it: # This condition says "...and the requested URL does not contain the string "/myblog/" RewriteCond %{REQUEST_URI} !^.*/myblog/.*$ [NC] However, all requests will be to mywebsite.com, anyway, so that test is unnecessary and can be omitted. All together: RewriteCond %{REMOTE_ADDR} ^111\.222\.333\.444$ RewriteCond %{REQUEST_URI} !^.*/myblog/.*$ [NC] RewriteRule ^.*$ hxxp://www.mywebsite.com/myblog/ [R=301,L] Edited June 23, 2009 by SteveW Quote Link to comment Share on other sites More sharing options...
mycat2 Posted June 24, 2009 Share Posted June 24, 2009 All together: RewriteCond %{REMOTE_ADDR} ^111\.222\.333\.444$ RewriteCond %{REQUEST_URI} !^.*/myblog/.*$ [NC] RewriteRule ^.*$ hxxp://www.mywebsite.com/myblog/ [R=301,L] Thanks so much for working with me on this - I added the above to the file, changing everything to the real info of course, and got the Redirect Loop error message... Quote Link to comment Share on other sites More sharing options...
SteveW Posted June 25, 2009 Share Posted June 25, 2009 (edited) I tried a similar set of rules in Apache2.2 here on my PC, and the initial redirect (of the page) works just as it should, but the page I'm redirecting to contains images, and all those get redirected, too. It doesn't result in an infinite loop, but the images don't display, with a red X where they should be. Hadn't thought of that. Sorry mycat2, in the next section between the dashes, I was confused between the original question and your later question. It might still contain useful info for someone, but maybe not for your situation: ---------- Going back to the original question, For years I had a "redirect" from the main home page (i.e. www.website.com/index.htm) to my blog home page (www.website.com/blog/index.htm) that's actually more specific (from one specific page to another specific page) than what the question has evolved into (from any page of the main site to the blog index), so let's try doing the more specific one. This redirect your home page: RewriteCond %{REMOTE_ADDR} ^111\.222\.333\.444$ RewriteCond %{REQUEST_URI} ^/(index\.htm)?$ [NC] RewriteRule ^.*$ hxxp://www.mywebsite.com/myblog/ [R=301,L] If the index page for your blog really IS called index.htm, then the code can be: RewriteCond %{REMOTE_ADDR} ^111\.222\.333\.444$ RewriteCond %{REQUEST_URI} ^/(index\.htm)?$ [NC] RewriteRule ^.*$ hxxp://www.mywebsite.com/myblog/index.htm [R=301,L] If you still get an infinite redirect loop, consider the possibility of other rewrite code in your .htaccess that is either interfering with this or interacting with it. Look for other lines in other code blocks starting with Rewrite: RewriteCond, RewriteRule, RewriteMatch... ---------- mycat2, can you describe exactly what page(s) you want to redirect to what other page. A URL ending with "/" isn't a page. What pages on your site are people going to, and which pages do you want to redirect them to? Edited June 25, 2009 by SteveW Quote Link to comment Share on other sites More sharing options...
SteveW Posted June 25, 2009 Share Posted June 25, 2009 (edited) Some other potentially conflicting lines in .htaccess are ones starting with Redirect such as RedirectMatch. It would help if you could post all the lines having to do with Rewrites and Redirects in the order they appear in the file, and omitting other .htaccess contents containing any private data. Is your entire website within /myblog/? No pages in public_html, no images in a folder such as /images/, nothing? What blog software, if any, are you using? Is the "Redirect Loop" error message one from Firefox saying something like, "FF has detected that the series of redirects will never end...?" Does it give you any other messages, such as the redirects that are being done? This FF add-on called Live HTTP Headers would give you some useful troubleshooting data: https://addons.mozilla.org/en-US/firefox/addon/3829. It shows the server's response headers as the page loads, so you get to see what redirects are being made. Edited June 25, 2009 by SteveW Quote Link to comment Share on other sites More sharing options...
mycat2 Posted June 26, 2009 Share Posted June 26, 2009 Some other potentially conflicting lines in .htaccess are ones starting with Redirect such as RedirectMatch. It would help if you could post all the lines having to do with Rewrites and Redirects in the order they appear in the file, and omitting other .htaccess contents containing any private data. Is your entire website within /myblog/? No pages in public_html, no images in a folder such as /images/, nothing? What blog software, if any, are you using? Is the "Redirect Loop" error message one from Firefox saying something like, "FF has detected that the series of redirects will never end...?" Does it give you any other messages, such as the redirects that are being done? This FF add-on called Live HTTP Headers would give you some useful troubleshooting data: https://addons.mozilla.org/en-US/firefox/addon/3829. It shows the server's response headers as the page loads, so you get to see what redirects are being made. Again I thank you for your time but I'm just going to just throw my hands in the air at this point - What was very very very simple to do 2 months ago (I did something very similar to this on another site) is now a full blown pain. Its just a wordpress blog whatever the lastest version is 2.8 I think installed via fantastico, and the errors were about cookies being on or off I don't remember exactly. I've had the site for a number of years and there are quite a few files in the public-html directory. My plan was to temporarily retire the site and just use the blog until I could figure out what to do with the site. It may just be best if I download everything off the server and put the blog in the root directory. Thanks again Steve! Quote Link to comment Share on other sites More sharing options...
click Posted June 30, 2009 Share Posted June 30, 2009 You might try something like this. It should redirect any requests for files that do not exist to your blog. As a transparent rewrite: >RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /myblog/ [L] Or as a 301: >RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . http://www.mywebsite.com/myblog/index.php [R=301L] Quote Link to comment Share on other sites More sharing options...
mycat2 Posted July 3, 2009 Share Posted July 3, 2009 (edited) You might try something like this. It should redirect any requests for files that do not exist to your blog. As a transparent rewrite: >RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /myblog/ [L] Or as a 301: >RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . http://www.mywebsite.com/myblog/index.php [R=301L] Thanks, tried both options but they did not work - my original index page loads. I have a number of redirects already set up, those redirect pages to another web site but I don't think that would effect this - I did try adding the different options above to the top, then to the bottom of the list but with the same result. Thanks for the suggestion! Edited July 3, 2009 by mycat2 Quote Link to comment Share on other sites More sharing options...
mycat2 Posted July 3, 2009 Share Posted July 3, 2009 (edited) sorry my reply posted twice when I tried to edit! Edited July 3, 2009 by mycat2 Quote Link to comment Share on other sites More sharing options...
click Posted July 3, 2009 Share Posted July 3, 2009 Sorry, I didn't think about there being an index page in public_html. If you rename that index page, I think it should work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.