URL rewrites to get 2 sites working

Discussion in 'Apache' started by ChocolateLover, Oct 26, 2010.

  1. #1
    I have a Drupal installation in a drupal subfolder, example.co.uk/drupal.

    I'm successfully rewriting this to example.co.uk using the following .htaccess in the root.


    RewriteEngine On

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php(\?[^\ ]*)?\ HTTP/

    RewriteRule ^(([^/]+/)*)index\.php$ http://www.example.co.uk/$1 [R=301,L]
    RewriteCond %{HTTP_HOST} ^(www.)?example.co.uk$


    RewriteRule ^$ /drupal/ [L]

    RewriteCond %{REQUEST_URI} !^/fckeditor/
    RewriteCond %{REQUEST_URI} !^/drupal/
    RewriteCond %{REQUEST_URI} !^/phpMyAdmin/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /drupal/$1


    RewriteCond %{HTTP_HOST} ^(www.)?example.co.uk$


    I've installed SugarCRM into a sugar folder, which I can access from example.co.uk/sugar, however when I try to log into Sugar I just get redirected to the login screen with no other messages. If I rename .htaccess I can log into Sugar, however my Drupal installation is then only accessible from example.co.uk/drupal and not example.co.uk.

    Can anyone tell me what to put in the example.co.uk root .htaccess to stop all example.co.uk/sugar urls being redirected?

    Any help gratefully received, thanks.
     
    ChocolateLover, Oct 26, 2010 IP
  2. cerno

    cerno Well-Known Member

    Messages:
    207
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    108
    #2
    this is what I would do
    create a subdomain of sugar.example.com at wherever your domain is held
    create a folder off of your html root folder of /sugar just like another website, it will alongside /drupal, not inside of it
    create a virtual server entry for the subdomain url address, now it will be accessible directly when you go to sugar.example.com
    put a standard drupal htaccess file back in place

    As a side note, it would be a good idea to change the name of your phpMyAdmin folder and adjust virtual host accordingly, there are robots constantly crawling around looking for phpmyadmin, it just feels safer not to put it where it could be found if you made a mistake with htaccess or something else

    Hope that helps,

    Cerno
     
    cerno, Oct 26, 2010 IP
  3. ChocolateLover

    ChocolateLover Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your help, I'll have a look at this.
     
    ChocolateLover, Oct 26, 2010 IP