Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

618 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