How do I hide the subdirectory name in the address bar?

Posted on 2006-06-21
Medium Priority
Last Modified: 2008-01-09
This is what I mean:

I have my site installed in the directory IHEA_47, one level below the root of http://ihea.info

So the path to the index page is http://ihea.info/ihea_47/home  (home is just a alias for the homepage).

In my Site5 hosting control panel i put in a redirection so http://ihea.info points to http://ihea.info/ihea_47 

What I want is that when the user arrives at http://ihea.info/ihea_47/home , he or she sees http://ihea.info/home and not the directory name the site installed. All navigation should be as if the site is in root folder.

How do I do that? I thought REDIRECTION would do that, but I keep seeing http://ihea.info/ihea_47 and all my absolute links inside my pages are broken now.

(I wrote the host a few hours ago and no response). They use the Cpanel. PHP running on Apache.
Question by:polaatx
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 15

Expert Comment

ID: 16959076
Try using an Alias instead:

Alias /home /full/path/to/ihea_47_home

withint hte VirtualHost container for ihea.info.
LVL 15

Expert Comment

ID: 16959088
Or... why not just change the ServerRoot in the httpd.conf file to be /full/path/to/idea_47 ?

Author Comment

ID: 16959349
Hello, could you tell me howto do this? where would I find the VirtualHost container ?

Your second idea: I don't think I have access to httpd.conf. I've asked the host by email but they won't answer me. But went through every directory in the root and found nothing.
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

LVL 15

Expert Comment

ID: 16960194
Unless you have access to restarting the apache web server, you don't have access to the httpd.conf.

Unfortunately, if you don't have access to that, I don't believe that you'll be able to add an Alias to the .htaccess file... but it's worth a try.

You need to create a file called .htaccess and with that line, and stick it in the root of your site.  Be prepared to delete it, though, if it doesn't work, it will render your site unaccessable.  

Author Comment

ID: 17022248
Hello, below is my current .htaccess residing in the root.

Could you kindly please tell me the exact code I should put in and where I should put it in.

Do I put in:

Alias /home /full/path/to/ihea_47_home

Is the above exact code or "path" is spaceholder for my particular path?

Here's my htaccess:

# Apache/PHP/Drupal settings:

# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|install|module|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root)$">
  Order deny,allow
  Deny from all

# Set some options.
Options -Indexes
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0

# PHP 4, Apache 2
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0

# PHP 5, Apache 1 and 2
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0

# Reduce the time dynamically generated pages are cache-able.
<IfModule mod_expires.c>
  ExpiresByType text/html A1

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the prefix www.
  # you can use one of the following settings to force user to use only one option:
  # If you want the site to be accessed WITH the www. only, adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
  # RewriteRule .* http://www.example.com/ [L,R=301]
  # If you want the site to be accessed only WITHOUT the www. , adapt and uncomment the following:
  # RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
  # RewriteRule .* http://example.com/ [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  #RewriteBase /drupal

  # Rewrite old-style URLs of the form 'node.php?id=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^id=([^&]+)$
  #RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form 'module.php?mod=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
  #RewriteRule module.php index.php?q=%1 [L]

  # Rewrite current-style URLs of the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

# $Id: .htaccess,v 1.73 2006/04/14 09:08:26 killes Exp $
LVL 15

Accepted Solution

periwinkle earned 2000 total points
ID: 17023550
RE: Alias /home /full/path/to/ihea_47_home
RE: Is the above exact code or "path" is spaceholder for my particular path?

/full/path/to  is a placeholder for your actual path;  for example, if on your server, ihea_47_home is in the /home/ihea/www/ihea_47_home directory, then you would use:

Alias /home /home/ihea/www/ihea_47_home

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

777 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