Solved

Mapping URL in PHP

Posted on 2007-11-16
15
1,541 Views
Last Modified: 2013-12-13
Configured wamp on windows 2003 server. Installed two applications 1. mrbs 2. wiki. If I type http://wiki.def.com, it goes to wamp main page. If I type http://mrbs.def.com/mrbs it goes to mrbs home page, if I type http://wiki.def.com/wiki it goes to wiki main page.
I need to map
1.http://mrbs.def.com/mrbs to http://mrbs.def.com
2. http://wiki.def.com/wiki to http://wiki.def.com
Please help. I am a beginner to PHP, MySQL, Apache.
0
Comment
Question by:abguttikonda
  • 8
  • 5
  • 2
15 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 20300376
You need to configure virtual hosts within the apache. See http://httpd.apache.org/docs/2.0/vhosts/name-based.html
0
 
LVL 3

Expert Comment

by:pmctrek
ID: 20300428
You need to add the code below to the end of the httpd.conf file in apache to tell it were to look when it receives the request from the client, and restart apache.

This code assumes that mrbs and wiki are sudirectories inside the htdocs directoy of apache, if not just replace the DocumentRoot with the complete path c:\www\wiki.

Paul
NameVirtualHost *:80
 

<VirtualHost *:80>

  ServerName mrbs.def.com

  ServerAlias mrbs

  DocumentRoot mrbs

</VirtualHost>
 

<VirtualHost *:80>

  ServerName wiki.def.com

  ServerAlias wiki

  DocumentRoot wiki

</VirtualHost>

Open in new window

0
 

Author Comment

by:abguttikonda
ID: 20301099
I have added the following code to the end of httpf.conf file and restarted all the services.
NameVirtualHost *:80
 <VirtualHost *:80>
  ServerName mrbs.def.com
  ServerAlias mrbs
  DocumentRoot C:\wamp\www\mrbs
</VirtualHost>
<VirtualHost *:80>
  ServerName wiki.def.com
  ServerAlias wiki
  DocumentRoot C:\wamp\www\wiki
</VirtualHost>

Now I am able to access mrbs with the URL : http://mrbs.def.com but
the URL: http://wiki.def.com/wiki is giving me 404 page not found. Please help.
0
 

Author Comment

by:abguttikonda
ID: 20301120
Sorry for the typo.
The URL : http://wiki.def.com is giving 404 page not found.
0
 
LVL 3

Expert Comment

by:pmctrek
ID: 20311231
What is the main page name? default.html, default.php, index.php,etc?  There is a setting in the httpd.conf that specifies what page to load.  by default apache only loads index.html so find the line

DirectoryIndex index.html index.html.var

and add the index.php to start or end of that line and you should be sorted.
0
 

Author Comment

by:abguttikonda
ID: 20311916
The following is the code under Directory index section of httpd,conf file. Please help if I am missing anything in this.
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.php3 index.html index.htm index.html.var
</IfModule>
#

I can send the httpd.conf file if you wanna take a look at it. Please treat this as urgent.
0
 

Author Comment

by:abguttikonda
ID: 20312337
When I check the apache error log I found the following error log:
[Mon Nov 19 08:51:55 2007] [error] [client a.b.c.d] File does not exist: C:/wamp/www/wiki/wiki
I am clueless why it is pointing to /wiki/wiki it should only point to /wiki
May be this will help you to advise a solution for me.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:pmctrek
ID: 20313038
Hi

it looks like it is looking for a file called wiki and not a folder.. what is the actual file name in the c:\wamp\www\wiki folder?

Paul
0
 
LVL 48

Expert Comment

by:hernst42
ID: 20313088
If you want to acces it via
http://wiki.def.com/wiki
and
http://wiki.def.com/

You need to add for the virtualhost

Alias /wiki C:\wamp\www\wiki

See http://httpd.apache.org/docs/2.2/mod/mod_alias.html
0
 

Author Comment

by:abguttikonda
ID: 20313675
Previously the following is the working link. At that time when I type in wiki.def.com or mrbs.def.com the page that is coming up is wamp main page. From that page when I click on the folder wiki, I was able to get wiki main page, when I click on mrbs I was able to get mrbs main page. Alternatively they were accessible with the URLS : http://wiki.def.com/wiki and http://mrbs.def.com/mrbs
the working link for wiki was http://wiki.def.com/wiki/index.php/Main_Page
I would like to access only via http://wiki.def.com


0
 
LVL 3

Expert Comment

by:pmctrek
ID: 20313782
I have 2 options, the first is a hack and the other is I have installed WAMP locally but you need to tell me which versions of mrbs and wiki you have installed and then I can fix the problem properly.

The hack solution is to alter the DirectoryIndex line to
   DirectoryIndex default.php index.php index.php3 index.html index.htm index.html.var

And then add the file below to your c:\wamp\www\wiki directory just ensuring that the file is named default.php.  This should cause the browser to do an internal site redirection to the wiki Main_Page.

Paul
<? PHP

header ('Location: /index.php/Main_Page');

?>

Open in new window

0
 

Author Comment

by:abguttikonda
ID: 20314098
MRBS 1.2.5, Media wiki 1.11
I have added the code as mentioned above. Now http://wiki.def.com is giving me a blank page.
Please help.
0
 
LVL 3

Accepted Solution

by:
pmctrek earned 500 total points
ID: 20314248
ok.. I found it.. the problem is with mediawiki not apache or wamp.. I installed the systems exactly the same way you did and everythink worked fine.  Then I set up the virtualhosts and suddenly wiki went nuts.  I just deleted the contents of the wiki directory and wided the database and reinstalled the whole thing using the wiki.def.com url to setup wiki and now it works perfect.

I have compared the two files and the only different I would find was the following

$wgScriptPath       = "/wiki";

in localsettings.php, change this to

$wgScriptPath       = "";

And see what happens.

Paul
0
 

Author Comment

by:abguttikonda
ID: 20316011
Thank you so much. You made my day. Everything works fine now. Once again thak you very much.
0
 

Author Closing Comment

by:abguttikonda
ID: 31409610
Thanks much for the Help, Paul. Really excellent and easy to understand your directions.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

762 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

19 Experts available now in Live!

Get 1:1 Help Now