Redirect with WAMP Server on Win 7 Pro Box

Hello Experts,

I have installed WAMP Server on a Windows 7 Pro 64-bit box to host a very very basic website. I also, have copied all of my website files to C:\wamp\www. However, when you type in http://www.contoso.com either locally or externally you get the WAMP Server Homepage (You also get it if you type in http://localhost). I suspect this is because my websites "Homepage" actually lives at  http://www.contoso.com/home/tech/home.html. How do I accomplish this, either with a "Redirect" or do I need to change the "Document Root pointer"?? This is the very first time I have ever messed with WAMP, and so any step by step information you could provide would be most helpful.
LVL 8
justinmoore14Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
COBOLdinosaurConnect With a Mentor Commented:
This is how I do the index in the root of my personal site which is where users land if they just enter coboldinosaur.com:

<?php
$location= $_SERVER['HTTP_HOST'] . '/COBOLdinosaur/pages/cdHome.html';
header("Location: http://$location");
exit;
?>

Open in new window


The manual page for the PHP header function is here:
http://php.net/manual/en/function.header.php

Cd&
0
 
COBOLdinosaurCommented:
You can use .htaccess to re-direct  using this generation tool to create the code for you:
http://www.htaccessredirect.net/

Though a more practical way to do it would be to put an index.php page in the root and re-direct with a header function.

Cd&
0
 
justinmoore14Author Commented:
Hello Cd&,

Thank you for your quick reply.

I will leave the .htaccess method on the back burner for the time being as a 2nd option. Since you say that the second method you listed above would be more practical. I have two questions though.

First, how would I go about creating a index.php file in the root (Do I just create a file and then call it index.php)?? What contents need to be in this file?

Second, how would I create the re-direct with a header function (What would be the code for this)?



Justin
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
justinmoore14Author Commented:
If I take the above code and create a "index.php file, but modify it with my information. I now get this page cannot be displayed. However, if I type in the full path (http://www.contoso.com/home/tech/home.html) my webpage displays properly and all my links work correctly. I take it this would mean that the web server portion is working properly, but just the first page that everyone needs to land on by typing in www.contoso.com still needs to be fixed??

Since I am not a developer by any stretch of the imagination I am having a little trouble finding where to insert the code into the default index.php file that was created when the WAMP Server was installed. Maybe the only thing I am missing is just the proper placement of the code in the .php file?? I have uploaded a copy of the index.php file that was created by the WAMP Server. Would you mind taking a look at it and seeing where I need to place the code you wrote above?

Side Note: Remember before when I use the default index.php file that was created by the WAMP Server; if I type in www.contoso.com I was getting the WAMP Landing page. I didn't know if this was useful information for you as your were reading down through the code?



Justin
index---Copy.php
0
 
COBOLdinosaurConnect With a Mentor Commented:
That index page is the default localhost/index.php.

All you need for your index.php is the code I posted above, but with your link.  That is the complete page.  

$_SERVER['HTTP_HOST'] is probably not working for you because you don't have localhost defined in the host file for 127.0.0.1 or you have a custom setup not running through port 80.

You need to go through httpd.config for Apache and the php.ini files to make sure you have setting that make maintenance easy. and paths work transparently.  It sounds like you are hosting a public facing site with WAMPserver, so you will want to be particularly careful about security settings in the httpd.config and php.ini to avoid getting hacked.

Cd&
0
 
justinmoore14Author Commented:
Ok, I checked the host file and I had two entries in there for 127.0.0.1 localhost, and so I deleted one of them.

Next I reviewed the code again that you posted above and found that on this line (HOST'] . '/) I had a dash instead of what looks like a period. Once I changed that everything seems to be working properly.

What do you suggest that needs to be changed in both the httpd.config and php.ini files??

Note: In the httpd.config file I found where you can put a specific IP address for the server to listen on, and also where you can change the specific user that it runs as.?? However, it says (If you wish httpd to run as a different user or group, you must run# httpd as root initially and it will switch). How would I do this??

I am also not even sure where to begin with php.ini file, but to keep confusion down we can just start with the httpd.config



Justin
0
 
COBOLdinosaurConnect With a Mentor Commented:
You want to be careful about changing the user in httpd.config as it could will likely cause permissions problems and may make some things inaccessible to Apache.  You should probably not need to play with the ip either.  As it is nor re-directing correctly , you should be able to leave the rest of HTTPD.config to the defaults.

As for php.ini any changes depend on how much php you are using, and how your pages get generated.  I you are usong static HTML pages you probably can use the defaults, other than setting the timezone and change the logging to go to a file instead of displaying.  Displaying errors is fine for a development environment, but for a public site you don't want to display errors as it may help a hacker find a vulnerability; and ALL site get visited by hackers sooner or later.

The php.ini that comes with wampserver is pretty well commented, but if you need more information about a setting you can look at: http://php.net/manual/en/ini.list.php

That is the list of php.ini settings from the PHP manual, and each of them has a link to the manual page with details about the setting.

Cd&
0
 
justinmoore14Author Commented:
Would changing the user not make it slightly harder to be hacked? I can create a dedicated user for this if needed. You said (As it is nor re-directing correctly)...Did you mean "not re-directing properly"?? Are you referring to our previous conversation where I was having trouble getting my website to redirect properly?? This has been resolved since you explained more about the index.php file.

I am not using any php...All my webpages are .html. I have found a php.ini-production file that is supposedly for use when you put your server in production. I used this file as a base, and then made the following changes that you recommend above.

Thank you for the link to additional info as this was most helpful.


Justin
0
 
COBOLdinosaurConnect With a Mentor Commented:
Typo from fat fingered dinosaur on a small keyboard should be:
As it is now re-directing correctly , you should be able to leave the rest of HTTPD.config to the defaults.

If you change the user then you don't really do anything to add protection against a hacker. If they get to the root with privilege then they will have control of the server no matter what the username is. Protection comes from securing thing properly, and on a windows box that is always difficult.  

I would never run a production website on a windows box, so I am not sure the best way to secure it.  I use wamp for development, because I sometimes need to run on client windows boxes, but I would not ever consider a backend running anything that was not unix based.  However, the purpose of being able to add users and specific IP is geared more to managing access for multi-site intranets I think.

If you are just doing static HTML pages then you don't really need to worry about PHP, or anything else on the backend.  Against static HTML pages a hacker is not going to get much of a chance to hack, as there is literally nothing to attack. and they would actually have to breach the O/S, not just the server to do any damage.

Cd&
0
 
justinmoore14Author Commented:
Lol...I know that feeling. :-)

I also appreciate you taking the time to further clarify your point on whether or not to change the user and IP address. I get your point about running stuff on a Windows box, but you still took the time to help me work through the issues I had rather then just saying "No Switch To Linux". Unfortunately, I just am not familiar enough with Linux, and have always been afraid that my not knowing (Forgetting To Close Something up) would also make me just as vulnerable. I guess this is just something at some point I need to overcome. Maybe this is something that I can work towards.

Yes, all my webpages are static, and so this is good information to know. Makes since...Thank you for explaining.

Lastly, but most importantly. Thank you for all your help working through my issue, and the additional questions I asked along the way. Hope you have a great rest of the week.



Justin
0
 
COBOLdinosaurCommented:
Spending time helping someone who is engaged and working through issues is the main reason I continue to use EE.  Glad we could get your issues resolved.

Cd&
0
All Courses

From novice to tech pro — start learning today.