Solved

Redirect with WAMP Server on Win 7 Pro Box

Posted on 2014-09-16
11
348 Views
Last Modified: 2014-09-23
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.
0
Comment
Question by:justinmoore14
  • 6
  • 5
11 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40326020
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
 
LVL 8

Author Comment

by:justinmoore14
ID: 40326350
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
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 40328565
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
 
LVL 8

Author Comment

by:justinmoore14
ID: 40330060
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
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 500 total points
ID: 40331278
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 8

Author Comment

by:justinmoore14
ID: 40331867
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
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 500 total points
ID: 40334381
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
 
LVL 8

Author Comment

by:justinmoore14
ID: 40336304
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
 
LVL 53

Assisted Solution

by:COBOLdinosaur
COBOLdinosaur earned 500 total points
ID: 40337632
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
 
LVL 8

Author Comment

by:justinmoore14
ID: 40339086
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
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40339463
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

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now