huntersj78 Posted December 9, 2009 Share Posted December 9, 2009 Sorry for asking stupid questions all the time guys (and gals). Ok there are two sites. www.dmj.fm and www.discoverymusic.jp The latter will eventually be phased out, but I am still using it as a base because of my databases that are still in use. I want to make only the home page (www.discoverymusic.jp) redirect to www.dmj.fm( www.dmj.fm redirects to http://junco-cheep.seesaa.net/) I put the same code as I did in dmj.fm and it works, but www.discoverymusic.jp doesnt. Here is the code I used in the index page. <?php header('location:http://junco-cheep.seesaa.net/'); ?> When you type www.discoverymusic.jp into the address bar it is just blank, but if you add index.html to the end it redirects just fine. What am I doing wrong?? :'( Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 9, 2009 Share Posted December 9, 2009 .htm? Add a .htaccess entry to force the index.htm file as the default opened page. DirectoryIndex index.htm Also, Most browsers will fail to read the header if it's not capitalized and in RFC format. header('Location: http://junco-cheep.seesaa.net/'); Once you place the .htaccess in root of www.discoverymusic.jp it should work fine. Quote Link to comment Share on other sites More sharing options...
huntersj78 Posted December 9, 2009 Author Share Posted December 9, 2009 WOW that is a fast response. Here is the original htaacces. AddType application/x-httpd-php .inc .html Is that not right? Sorry I am just a beginner. The htm in the title was a typo.. I have the index.html in the root along with the above htaacces. Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 9, 2009 Share Posted December 9, 2009 WOW that is a fast response. Here is the original htaacces. AddType application/x-httpd-php .inc .html Is that not right? Sorry I am just a beginner. The htm in the title was a typo.. I have the index.html in the root along with the above htaacces. Then try this as your .htaccess: DirectoryIndex index.html AddType application/x-httpd-php .inc .html The addtype simply allows parsing of PHP code in a .html document.. in case you did not know. Quote Link to comment Share on other sites More sharing options...
huntersj78 Posted December 9, 2009 Author Share Posted December 9, 2009 WOW that is a fast response. Here is the original htaacces. AddType application/x-httpd-php .inc .html Is that not right? Sorry I am just a beginner. The htm in the title was a typo.. I have the index.html in the root along with the above htaacces. Then try this as your .htaccess: DirectoryIndex index.html AddType application/x-httpd-php .inc .html The addtype simply allows parsing of PHP code in a .html document.. in case you did not know. Doesnt redirect just stays blank. If I manually type index.html after the url it redirects though. And thanks for the addtype tip. Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 9, 2009 Share Posted December 9, 2009 That's telling the server to forcefully open index.html. I haven't a clue why you need to enter it after typing that. Try removing index.html and .htaccess and just create a new index.php with the redirection code, There's nothing you're doing that should warrant having to physically enter it, I'm not sure how your server is set up. Quote Link to comment Share on other sites More sharing options...
huntersj78 Posted December 9, 2009 Author Share Posted December 9, 2009 Thanks Oni-Kun. I hope I will be able to figure it out. Quote Link to comment Share on other sites More sharing options...
Deoctor Posted December 9, 2009 Share Posted December 9, 2009 if ur using the xampp then do this under the apache folder there will be conf folder which has httpd.conf, open it with any text editor and check for the line 249 < IfModule dir_module> DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \ default.php default.pl default.cgi default.asp default.shtml default.html default.htm \ home.php home.pl home.cgi home.asp home.shtml home.html home.htm </IfModule> and see for this <IfModule change it like which i have shown above this should resolve the issue Quote Link to comment Share on other sites More sharing options...
huntersj78 Posted December 9, 2009 Author Share Posted December 9, 2009 if ur using the xampp then do this under the apache folder there will be conf folder which has httpd.conf, open it with any text editor and check for the line 249 < IfModule dir_module> DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \ default.php default.pl default.cgi default.asp default.shtml default.html default.htm \ home.php home.pl home.cgi home.asp home.shtml home.html home.htm </IfModule> and see for this <IfModule change it like which i have shown above this should resolve the issue Thanks for your help but all I know is that I am renting a server. I have access to it but I dont know where to look for the above. I ususally do everything through FTP. Quote Link to comment Share on other sites More sharing options...
Deoctor Posted December 9, 2009 Share Posted December 9, 2009 ask ur server administrator to set the default page to be index.html for all ur sites Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 9, 2009 Share Posted December 9, 2009 I forgot. You can leave out the html page all together and just use this. Clear out your .htaccess file or append this line, but it'll be a more compatible method of redirection: Simple: redirect 301 / http://junco-cheep.seesaa.net/ Or.. Using mod_rewrite (try this instead of simple method.): RewriteCond %{HTTP_HOST} ^(www\.)?discoverymusic\.jp [NC] RewriteRule ^(.*)$ http://junco-cheep.seesaa.net/$1 [R=301,L] Do those work? Quote Link to comment Share on other sites More sharing options...
huntersj78 Posted December 9, 2009 Author Share Posted December 9, 2009 I forgot. You can leave out the html page all together and just use this. Clear out your .htaccess file or append this line, but it'll be a more compatible method of redirection: Simple: redirect 301 / http://junco-cheep.seesaa.net/ Or.. Using mod_rewrite (try this in place of simple method.): RewriteCond %{HTTP_HOST} ^(www\.)?discoverymusic\.jp [NC] RewriteRule ^(.*)$ http://junco-cheep.seesaa.net/$1 [R=301,L] Does this work? I will try it now. I will stick to the simple because I have no idea how to use mod_rewrite yet.. I will let you know. Quote Link to comment Share on other sites More sharing options...
oni-kun Posted December 9, 2009 Share Posted December 9, 2009 I did the full mod_rewrite for you there, if the first method doesn't work (second redirects any part of the domain to work better) so you have no need to write it yourself, but yeah, It should work. What they do, is it tells the server to send a 301 (redirection) code to the client telling them to go to the secondary domain. This is more serverside rather than just telling the client to go somewhere else, so it can't be a blank page like you saw before. Quote Link to comment Share on other sites More sharing options...
huntersj78 Posted December 9, 2009 Author Share Posted December 9, 2009 I did the full mod_rewrite for you there, if the first method doesn't work (second redirects any part of the domain to work better) so you have no need to write it yourself, but yeah, It should work. What they do, is it tells the server to send a 301 (redirection) code to the client telling them to go to the secondary domain. This is more serverside rather than just telling the client to go somewhere else, so it can't be a blank page like you saw before. Can you check out my server and see if I have the right module for a mod_rewrite? http://www.discoverymusic.jp/phpinfo.php Also do I do the rewrite on the htaccess file? Quote Link to comment Share on other sites More sharing options...
huntersj78 Posted December 9, 2009 Author Share Posted December 9, 2009 I forgot. You can leave out the html page all together and just use this. Clear out your .htaccess file or append this line, but it'll be a more compatible method of redirection: Simple: redirect 301 / http://junco-cheep.seesaa.net/ Or.. Using mod_rewrite (try this in place of simple method.): RewriteCond %{HTTP_HOST} ^(www\.)?discoverymusic\.jp [NC] RewriteRule ^(.*)$ http://junco-cheep.seesaa.net/$1 [R=301,L] Does this work? I will try it now. I will stick to the simple because I have no idea how to use mod_rewrite yet.. I will let you know. Ok so I tried the 301, but it redirected everything...ouch. I only want it to redirect the main url. I still use some of the sub folders until I can figure out how to change over my databases. I guess I am stuck with the blank page until I can get around this. Quote Link to comment Share on other sites More sharing options...
huntersj78 Posted December 9, 2009 Author Share Posted December 9, 2009 Why is it that when I manually enter the index.html after www.discoverymusic.jp it will redirect, but not the url itself. I dont want the whole site redirected just the index page. Quote Link to comment Share on other sites More sharing options...
huntersj78 Posted December 9, 2009 Author Share Posted December 9, 2009 THANKS to all who have helped and special thanks to oni-kun who stuck in there and figured me a way out of my hole. PHPFREAKS RULE!!!! 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.