I am sure this has been touched upon many times before but I have been searching drupal.org for half the day and cannot figure out how to do this.

how do I remove the 'drupal' component from all my drupal URL paths. i.e.

mysite.com/drupal/blahblah

to just

mysite.com/blahblah

Ive played with changing things in my .htaccess and settings.php from '/drupal' to just '/'
but I only get page not found errors.

My drupal install is in a subdirectory of my public_html folder.

How is this done?

Comments

teshager’s picture

I always use Linux symbolic links, which will help you achieve the functionality you're looking for. Basically do this

1. Assuming you've shell access to your installation path on a hosting site
ln -s drupal blahblah

2. In your website setup point to mysite.com/blahbalh and all will work.

Have fun.
/c4rider

psr’s picture

yes thats good but i think i did not clearly explain my path situation.

i want to remove all /drupal elements from my site paths, but i wont necessarily have the blahblah directory there to act as a stand-in.

ie sometimes it will be mysite.com/nodes; mysite.com/book etc.

how do i do this symbolic linking for a more general condition such as:

mysite.com/drupal
changed to:
mysite.com/

I had just used the blahblah because I still want all the other path info for the new url but just without the /drupal in between mysite.com and the rest of the path.

can i make a symbolic link to a top level directory without it showing up in the url path? (unix-tard=me)
ie my drupal dir is in public_html (/public_html/drupal)
so would i do something like:
ln -s drupal public_html ?
and then change everything in my settings.php and .htaccess to just '/' rather that '/drupal',

Chill35’s picture

how do i do this symbolic linking for a more general condition such as:

mysite.com/drupal
changed to:
mysite.com/

Why not use subdomain ? Or just make your domain point to that drupal folder ?

Caroline
A coder's guide to file download in Drupal
Who am I | Where are we
11 heavens

devx’s picture

why don't you just install drupal in /public_html and now /public_html/drupal ?

psr’s picture

yes I have tried this but I was not able to get the site to work without the /drupal in the url

when i moved my drupal directory to public_html, I changed my settings.php and settings1.php docs from /drupal to just '/' and i converted all the '/drupal' in my .htaccess to '/'. This did not work. when i typed in mysite.com the server would think about it for a second and then default to mysite.com/drupal with a not found error.

I also had my service provider change a config file for redirecting but this did not work either.

Can someone please provide me with the specifics of which file components in the drupal directory i will have to change and what to change them to if I move my drupal directory to public_html in order to make this new configuration work?

PS anyone know why/how drupal.org is not drupal.org/drupal?

cog.rusty’s picture

You don't have to modify anything at all, either in settings.php or in .htaccess. Normally you put Drupal's files and subdirectories in public_html, you go to yoursite.com to make the installer run and it just works.

There is no "/drupal" directory involved if you don't use one. The only reference to a "/drupal" directory is in .htaccess in a comment line, which doesn't affect anything.

If you have made changes which have introduced a "/drupal" directory in settings.php or in .htaccess, just replace those files with fresh ones from the distribution and enter your $db_url in the new settings.php and nothing else.

cog.rusty’s picture

I have followed many long threads in the past about what you ask and no suggested solution worked reliably in a standard shared hosting setup where you have a single public_html web root.

The problem with using a symlink is that you would have to make your public_html itself a symlink, which usually is not possible. Some suggestions were getting close by using a public_html/index.php symlink file which was pointing to the real public_html/drupal/index.php, plus some more symlinks in public_html pointing to drupal's real subdirectories and important files. But that was messy (required a bunch of symlinks in public_html) and not always reliable.

From what I have read and tried so far, I think that if you can't have your host point a new domain to the subdirectory you want, you will have to
- either use a subdomain for you subdirectory
- or accept dumping drupal into public_html.
as other suggested.

Actually I did get it working somehow by removing (renaming) another domain's public_html directory and replacing it with a symlink pointing to the existing site's drupal subdirectory.

mv (blah)/site2/public_html (blah)/site2/public_html_OFF
ln -s (blah)/site1/public_html/drupal (blah)/site2/public_html

So, I got site2.com working instead of site1.com/drupal. I didn't test it thoroughly because I found it ugly and tricky, so I reverted everything to the way it was and dumped drupal's files into public_html.

Another thing you could try is change the "drupal" subdirectory to something more acceptable such as "content" and use an apache rewrite to always send the user to /content. I think theonion.com has done something similar.

test127’s picture

The easiest way to solve this problem is to just not use a subdirectory in the first place. If necessary, use a subdomain, but not a subdirectory.

Chill35’s picture

Use subdomains for your subdirectories.

Caroline
A coder's guide to file download in Drupal
Who am I | Where are we
11 heavens

psr’s picture

I understand the words and concept you use to describe this, but I do not know how to actually do this

Could someone please briefly describe how I would go about using subdomains as subdirectories? I have ssh access and the control panel for my server provides the ability to make 'subdomain.mysite.com', is there another tool for accomplishing what you mean?

cog.rusty’s picture

Normally you do this from your control panel.

Usually there is an option for creating subdomains. You create a subdomain such as subdomain.example.com, and this automatically creates a directory public_html/subdomain. You use that directory while the users access it as http://subdomain.example.com and not as a subdirectory.

This is what subdomains are about.

fletch@blog.drupal.ro’s picture

I know this thread is several months old, but I am having the same troubles with removing /drupal from the url. It doesn't seem like it should be as difficult as some of the suggestions and I would like to avoid using a subdomain/directory. Any assistance would be helpful.

Thanks in advance...

ianooi’s picture

After a fresh install of Drupal 6.9 in Godaddy.

Step 1:
Create .htaccess file with Notepad (no word wrap) and save it in the root folder (ASCII FTP).

RewriteEngine on
RewriteRule (.*) drupal/$1 [L]

Step 2:
Modify settings.php file in drupal/sites/defaults.

$base_url = 'http://www.yourdomain.com';

If you can't modify the file then you need to change the write permissions using File Manager.

Pianoforte’s picture

I had the same issue also, this was the best solution. Thanks!!!!!!

vandana_bvj’s picture

Works like magic...

jspotswood’s picture

I have used the suggested solution in Drupal 6 quite successfully. But it does not work for Drupal 7. Anyone got this working in D7?

jspotswood’s picture

Thanks to Stack Overflow, the solution has been found. Reference:
http://stackoverflow.com/questions/5716839/how-to-remove-drupal-from-url...

piyushohri’s picture

Thank you all, this post helped a lot in resolve the redirection for "drupal" Install directory.

With this, I came across, another challenge.
There are couple of directory, at the same level as 'drupal' which I am unable to access now from inside drupal nodes (like pages / block).

Configuration:
Using Drupal 6.2, on GoDaddy Server (Linux hosted)
Directory structure
html (root-level)
\_ drupal (level 1)
\_ images (level 1)
\_ wms (level 1) -- this is an application
\_ ... (level 2, 3, ...)

Background (Why this structure):
I am working on an application, the directory structure, of which I have kept outside Drupal's structure.
(This is to provide independence of design, the representation of processing result, are handled using Drupal)

Problem at hand:
Durpal nodes accessing directory "/wms" or "/images" fail to reach desired files insides these directories.
for e.g. image file are not accessible and fail to show on page, similarly (and more important - appl. files too)

Looking for:
In addition to the given re-direct rule, any additional rules that would not change (redirect URLs) where the URL start with "/wms" and "/images" etc., even if they originate from Drupal nodes or anywhere else.

Working Until: Drupal nodes were able to access these (wms, images) directories prior to above config changes.

Recent configuration changes:
Added Rewrite rule in root directory and "base_url" updated (as given above).

I am a business functional person, trying to venture in technical space, hence has a very short-hand to technology.
Appreciate all your help.

mass43’s picture

If you are hosted by OVH

you've got to write this in your .htaccess :

RewriteEngine on
RewriteRule (.*) drupal/$1 [L]
SetEnv REGISTER_GLOBALS 0
SetEnv PHP_VER 5

vyeluri’s picture

Hi,

I have tried using this code but I couldnt get it.
error - 500 internal server error

Please reply. Thanks

ezaspie’s picture

This worked very well for me without the move.

ln -s blah/drupal6/* /blah/public_html/

nocturnalknight’s picture

I recently upgraded my drupal-site to 6.X and found many of my modules to be incompatible with it and had to revert to 5.1.
I've reverted and somehow corrupted the installation , now I can't get to delete sites\default\settings.php and defaultsettings.php , I've tried CHMODing to 777 and had tried to delete it via FTP and shell to anvil, any pointers will be appreciated.
Thanks,
Ram

cog.rusty’s picture

Drupal 6, for some security reason (which I don't understand) makes completely unwritable by the user account both the settings.php file (444) and the containing directory (555).

So, you need to chmod them back to 644 and 755 respectively to be able to write with FTP. (Then Drupal will make them unwritable again automatically, which makes this security measure a pain).

If you have updated the database to Drupal 6 by running update.php, then there is practically no way to go back to Drupal 5, except from a database backup.

dehacker’s picture

worked for me using 6.15

terk3d’s picture

i tryed some of the things on here and it gives me page can not be displayed changing the .htass file or what ever it is

any update on this for us newbies?