Hack Forums
How to redirect url.com to url.com/home - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Webmasters (https://hackforums.net/forumdisplay.php?fid=141)
+---- Forum: Website Construction (https://hackforums.net/forumdisplay.php?fid=50)
+---- Thread: How to redirect url.com to url.com/home (/showthread.php?tid=5129042)



How to redirect url.com to url.com/home - Underworldproblem - Jan 10, 2016

I believe there is a way to do this because I have done this before, but forgot the code. I would really appreciate this. Thanks.

I think I need like a htaccess file?


* - Frenzied - Jan 10, 2016

Rename your home directory to index.php or index.html, I think haha


* - Krew - Jan 10, 2016

Edit ".htaccess"
Input: "DirectoryIndex /home"
Done.


* - ۤMD5 - Jan 10, 2016

Index.php:
<?php headers("Location: /home"); ?>


* - Underworldproblem - Jan 10, 2016

in my public_html i have 0 files. but if i go to public_html/ home, my website is in there.

so if someone goes to my website ( url.com ) they will get a blank page, unless they type url.com/home

so how can i fix that?


* - Krew - Jan 10, 2016

(Jan 10, 2016 02:05 PM)❤️ HYFR ❤️ Wrote:  in my public_html i have 0 files. but if i go to public_html/ home, my website is in there.

so if someone goes to my website ( url.com ) they will get a blank page, unless they type url.com/home

so how can i fix that?

I gave you the solution already.
Place a .htaccess file in your main directory with the contents.


* - King of Diamonds - Jan 10, 2016

htaccess

Code
Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteCond %{SCRIPT_FILENAME} !-f

  RewriteRule ^.*$ ./index.php

Thats what i use for my website, but i think you can use:
Code
DirectoryIndex /home



* - ۤMD5 - Jan 10, 2016

(Jan 10, 2016 02:05 PM)❤️ HYFR ❤️ Wrote:  in my public_html i have 0 files. but if i go to public_html/ home, my website is in there.

so if someone goes to my website ( url.com ) they will get a blank page, unless they type url.com/home

so how can i fix that?

In the www root create a file called index.php and put this in:
<?php headers("Location: /home"); ?>


* - minimalist - Jan 10, 2016

Code
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?jyourdomainhere.net$
RewriteRule ^(/)?$ directoryto/redirectto [L]

File you can just edit and paste into your public_html
http://expirebox.com/download/acb26186696e2fa695bac29979d70480.html


* - Underworldproblem - Jan 10, 2016

One more problem.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?jyourdomainhere.net$
RewriteRule ^(/)?$ directoryto/redirectto [L]

Works.

Except I had to remove 'j' (www.)?jyourdomainhere.net$
Was that an error? or was i wrong to remove it

Also, directoryto i put home, is the redirectto the same? home?


* - Rushax - Jan 10, 2016

OP surely you want your website to redirect to
http://www.domain.com
NOT
http://www.domain.com/home

Whose going to remember to add /home on the end?

If I were you, I would transfer all files to public_html folder so it comes under the initial root directory.


If you still want to continue on with home the code given in the example above for .htaccess file:

OR you could upload a file within the root directory with
Code
<?php  header( 'Location: http://www.domain/home' ) ;  ?>
Naming the file index.php

Would not advise this method though as it might affect SEO results.