rewriting url from one directory to top of another

Discussion in 'Installation/Configuration' started by DantePasquale, Feb 8, 2011.

  1. DantePasquale

    DantePasquale Member HowtoForge Supporter

  2. falko

    falko Super Moderator ISPConfig Developer

    Are there any errors in Apache's error log?

    Do you use AllowOverride All in the vhost?
     
  3. DantePasquale

    DantePasquale Member HowtoForge Supporter

    Hi Falko,

    No errors reported in apache logs.

    Seems I have a mix of AllowOverride statements in the vhost file, but I think it should be OK the way it is. What are your thoughts?

    Here's the vhost file:
    cat cocoanet.us.vhost

    Code:
     
    <Directory /var/www/cocoanet.us>
        [B]AllowOverride None[/B]
        Order Deny,Allow
        Deny from all
    </Directory>
    
    <VirtualHost 74.1.46.163:80>
          DocumentRoot /var/www/cocoanet.us/web
      
        ServerName cocoanet.us
        ServerAlias *.cocoanet.us 
        ServerAlias photography.cocoanet.us 
        ServerAlias blog.cocoanet.us
        ServerAdmin [email protected]
    
        ErrorLog /var/log/ispconfig/httpd/cocoanet.us/error.log
    
    
        ErrorDocument 400 /error/400.html
        ErrorDocument 401 /error/401.html
        ErrorDocument 403 /error/403.html
        ErrorDocument 404 /error/404.html
        ErrorDocument 405 /error/405.html
        ErrorDocument 500 /error/500.html
        ErrorDocument 503 /error/503.html
    	
        <Directory /var/www/cocoanet.us/web>
            Options FollowSymLinks
            [B]AllowOverride All[/B]
            Order allow,deny
            Allow from all
            
            # ssi enabled
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Options +Includes
        </Directory>
        <Directory /var/www/web1/web>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
            
            # ssi enabled
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Options +Includes
        </Directory>
    
    
        # cgi enabled
    	<Directory /var/www/web1/cgi-bin>
          Order allow,deny
          Allow from all
        </Directory>
        ScriptAlias  /cgi-bin/ /var/www/web1/cgi-bin/
        AddHandler cgi-script .cgi
        AddHandler cgi-script .pl
        # Clear PHP settings of this website
        <FilesMatch "\.ph(p3?|tml)$">
            SetHandler None
        </FilesMatch>
        # mod_php enabled
        AddType application/x-httpd-php .php .php3 .php4 .php5
        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i [email protected]"	
        php_admin_value upload_tmp_dir /var/www/web1/tmp
        php_admin_value session.save_path /var/www/web1/tmp
    	# PHPIniDir /var/www/conf/web1
        php_admin_value open_basedir /var/www/web1/web:/var/www/web1/tmp:/var/www/cocoanet.us/web:/srv/www/cocoanet.us/web:/usr/share/php5:/tmp:/usr/share/phpmyadmin:/var/www/web1/usr/bin:/usr/bin
        
        RewriteEngine on
        RewriteCond %{HTTP_HOST}   ^photography.cocoanet.us [NC]
        RewriteRule   ^/(.*)$ /dantepasquale/$1  [L]
        RewriteCond %{HTTP_HOST}   ^blog.cocoanet.us [NC]
        RewriteRule   ^/(.*)$ /blog/dantepasquale/$1  [L]
    
        # add support for apache mpm_itk
        <IfModule mpm_itk_module>
          AssignUserId web1 client1
        </IfModule>
    
        <IfModule mod_dav_fs.c>
          # DO NOT REMOVE THE COMMENTS!
          # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
          # WEBDAV END
        </IfModule>
    
    
    </VirtualHost>
    
    
    
    <IfModule mod_ssl.c>
    ###########################################################
    # SSL Vhost
    ###########################################################
    
    <VirtualHost 74.1.46.163:443>
          DocumentRoot /var/www/cocoanet.us/web
      
        ServerName cocoanet.us
        ServerAlias *.cocoanet.us 
        ServerAlias photography.cocoanet.us 
        ServerAlias blog.cocoanet.us
        ServerAdmin [email protected]
        
        ErrorLog /var/log/ispconfig/httpd/cocoanet.us/error.log
    
        ErrorDocument 400 /error/400.html
        ErrorDocument 401 /error/401.html
        ErrorDocument 403 /error/403.html
        ErrorDocument 404 /error/404.html
        ErrorDocument 405 /error/405.html
        ErrorDocument 500 /error/500.html
        ErrorDocument 503 /error/503.html
    
        SSLEngine on
        SSLCertificateFile /var/www/web1/ssl/cocoanet.us.crt
        SSLCertificateKeyFile /var/www/web1/ssl/cocoanet.us.key
        
    	<Directory /var/www/cocoanet.us/web>
            Options FollowSymLinks
            [B]AllowOverride All[/B]
            Order allow,deny
            Allow from all
            
            # ssi enabled
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Options +Includes
        </Directory>
        <Directory /var/www/web1/web>
            Options FollowSymLinks
            [B]AllowOverride All[/B]
            Order allow,deny
            Allow from all
            
            # ssi enabled
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Options +Includes
        </Directory>
    
        # cgi enabled
    	<Directory /var/www/web1/cgi-bin>
          Order allow,deny
          Allow from all
        </Directory>
        ScriptAlias  /cgi-bin/ /var/www/web1/cgi-bin/
        AddHandler cgi-script .cgi
        AddHandler cgi-script .pl
        # ssi enabled
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
    # Clear PHP settings of this website
        <FilesMatch "\.ph(p3?|tml)$">
            SetHandler None
        </FilesMatch>
        # mod_php enabled
        AddType application/x-httpd-php .php .php3 .php4 .php5
        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i [email protected]"	
        php_admin_value upload_tmp_dir /var/www/web1/tmp
        php_admin_value session.save_path /var/www/web1/tmp
    	# PHPIniDir /var/www/conf/web1
        php_admin_value open_basedir /var/www/web1/web:/var/www/web1/tmp:/var/www/cocoanet.us/web:/srv/www/cocoanet.us/web:/usr/share/php5:/tmp:/usr/share/phpmyadmin:/var/www/web1/usr/bin:/usr/bin
        
        RewriteEngine on
        RewriteCond %{HTTP_HOST}   ^photography.cocoanet.us [NC]
        RewriteRule   ^/(.*)$ /dantepasquale/$1  [L]
        RewriteCond %{HTTP_HOST}   ^blog.cocoanet.us [NC]
        RewriteRule   ^/(.*)$ /blog/dantepasquale/$1  [L]
    
        # add support for apache mpm_itk
        <IfModule mpm_itk_module>
          AssignUserId web1 client1
        </IfModule>
    
        <IfModule mod_dav_fs.c>
          # DO NOT REMOVE THE COMMENTS!
          # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
          # WEBDAV BEGIN
          # WEBDAV END
        </IfModule>
    </VirtualHost>
    </IfModule>
    
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    If you use rewrite rules to rewrite the domain to the subdirectory:

    RewriteCond %{HTTP_HOST} ^photography.cocoanet.us [NC]
    RewriteRule ^/(.*)$ /dantepasquale/$1 [L]
    RewriteCond %{HTTP_HOST} ^blog.cocoanet.us [NC]
    RewriteRule ^/(.*)$ /blog/dantepasquale/$1 [L]

    then you can not use a .htaccess file with rewrite rules in that directory where the other rewrite rule points to.
    If a subdomain shall have its own directory, then create new website for that subdomain.
     
  5. DantePasquale

    DantePasquale Member HowtoForge Supporter

    Hi Till, Thanks I was wondering about that.

    However, I may have a different issue, then.

    In ISPConfig -> Sites -> cocoanet.us -> Options -> Apache Directives there is nothing displayed. Can I put the directory re-write rule here?

    I don't really need those sub-domains and I can delete the them if that simplifies things.

    I do have 'auto subdomain' set to *. but that would result in a different rule, wouldn't it?

    Danté
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Yes.

    Auto subdomain is not a rewrite rule, it is just a wildcard server alias directive in the apache vhost. So there should be no problems with this setting regarding rewrite rules.
     

Share This Page