Remove drupal from URL?

Discuss practical ways rearrange URLs using mod_rewrite.

Remove drupal from URL?

Postby dlester03 » Thu Nov 06, 2008 10:23 am

Hi, I am new obviously and having some problems. I have a hosting account and Drupal is installed in the /drupal subdirectory. So my main hosting directory is /html and the drupal is installed in /html/drupal

I have figured out how to redirect from the /html/ directory to /html/drupal/ and also how to remove the www from the URL.

Now I am trying to get rid of /drupal/

So all my URLS show up with http://mysite.org/drupal/content/<name_of_content_page>

What I want to do is remove the /drupal/ from all my URLs. I'm sure it is relatively simple to do but not being good at regular expressions and new the .htaccess file has frustrated me for the last couple of days while I searched around for an answer.

Thanks
dlester03
 
Posts: 5
Joined: Thu Nov 06, 2008 10:06 am

Postby dj_spykey » Fri Nov 07, 2008 5:11 am

make a backup to your site...save it on your computer...delete drupal and then reinstall it in /html/
dj_spykey
 
Posts: 8
Joined: Mon Nov 03, 2008 11:39 pm

Postby dlester03 » Fri Nov 07, 2008 7:29 am

dj_spykey wrote:make a backup to your site...save it on your
computer...delete drupal and then reinstall it in /html/


Well, I'm kind of hoping that this isn't the best answer I can get. I have a production site running in the /html directory and I've built the new site in /drupal under /html

Thanks for your advice though. I will consider it if I end up having to start all over again.
dlester03
 
Posts: 5
Joined: Thu Nov 06, 2008 10:06 am

Postby richardk » Fri Nov 07, 2008 11:47 am

Do you have mod_rewrite for Durpal already?
Where is the Durpal mod_rewrite?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby dlester03 » Sun Nov 09, 2008 7:11 am

richardk wrote:Do you have mod_rewrite for Durpal already?
Where is the Durpal mod_rewrite?


I have path and pathauto installed and I am able to use clean URLs. I cannot find a mod_rewrite module for drupal but maybe I am not looking for it in the correct place. I seached for rewrite all through the drupal.org modules page and there is nothing there for mod_rewrite modules.

I do have clean URLs enabled in drupal. Are you suggesting that I should use clean URLs and manually rewrite all my pages to remove drupal as part of the URL?

or are you asking me if I have a .htaccess file in /drupal directory? The answer to this question is yes.

Thanks

Dave
dlester03
 
Posts: 5
Joined: Thu Nov 06, 2008 10:06 am

Postby richardk » Sun Nov 09, 2008 11:55 am

or are you asking me if I have a .htaccess file in /drupal directory? The answer to this question is yes.

Yes, post it's contents. Do you have a .htaccess file in your document root? (The .htaccess file will need to be moved to your document root.)
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby dlester03 » Sun Nov 09, 2008 1:40 pm

richardk wrote:
or are you asking me if I have a .htaccess file in /drupal directory? The answer to this question is yes.

Yes, post it's contents. Do you have a .htaccess file in your document root? (The .htaccess file will need to be moved to your document root.)


This is the that came with Drupal. I only made one change and that was to uncomment the Rewrite base /drupal line. I should put this one in my /html directory as well?


#
# Apache/PHP/Drupal settings:
#

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

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# 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_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>

# 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_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>

# 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
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On

# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600

# Do not cache dynamically generated pages.
ExpiresByType text/html A1
</IfModule>

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

# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>



# $Id: .htaccess,v 1.90.2.1 2008/07/08 09:33:14 goba Exp $
dlester03
 
Posts: 5
Joined: Thu Nov 06, 2008 10:06 am

Postby richardk » Mon Nov 10, 2008 2:35 pm

Try the following in your document root
Code: Select all
Options +FollowSymLinks  -Indexes
ErrorDocument 404 /index.php
DirectoryIndex index.php

<FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
  Order allow,deny
</FilesMatch>

<IfModule mod_php4.c>
  php_value magic_quotes_gpc 0
  php_value register_globals 0
  php_value session.auto_start 0
  php_value mbstring.http_input pass
  php_value mbstring.http_output pass
  php_value mbstring.encoding_translation 0
</IfModule>

<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc 0
  php_value register_globals 0
  php_value session.auto_start 0
  php_value mbstring.http_input pass
  php_value mbstring.http_output pass
  php_value mbstring.encoding_translation 0
</IfModule>

<IfModule mod_php5.c>
  php_value magic_quotes_gpc 0
  php_value register_globals 0
  php_value session.auto_start 0
  php_value mbstring.http_input pass
  php_value mbstring.http_output pass
  php_value mbstring.encoding_translation 0
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault A1209600
  ExpiresByType text/html A1
</IfModule>

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ /durpal/index.php?q=$1 [QSA,L]
</IfModule>


You will probably need to change your Durpal base path to get your links to change.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby dlester03 » Tue Nov 11, 2008 2:53 am

Hi Richard,

Thank you for your help. I put that code into the .htaccess in my /html directory which is the parent of /drupal. I don't see any difference in the URL structure. I guess I am going to have to try re-installing Drupal once I get the new site the way I want it. I can just back it up and reinstall and reload my content.

Dave
dlester03
 
Posts: 5
Joined: Thu Nov 06, 2008 10:06 am

Postby richardk » Wed Nov 12, 2008 12:30 pm

What happens if you go to /content/<name_of_content_page>?

Mod_rewrite doesn't change anything, it only works on the incoming requests. To change your links you will need to look for a base path variable within Durpal.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 28 guests

cron