Rewrites problem with trailing "/" (Slash) on non-www domain.ext

Discussion in 'Installation/Configuration' started by yuro, Oct 15, 2008.

  1. yuro

    yuro New Member

    Hey guys,

    So I have Magento running and configured to "domain.ext". When I created the original domain in ISPConfig, I had set it up as "www.domain.ext", then add "domain.ext" in the co-domain.

    As I see, when I type in "www.domain.ext", it then gets forwarded/rewritten to "domain.ext/". All links within Magento that lead to products do not have a trailing slash, yet it is added and then shows, "domain.ext/productname.html/". Just as an aside, I don't get any 404 errors, and the product page does show up.

    As a test, I created a new website with "shop.domain.ext" and installed magento accordingly with sample data. The problem I am writing about is not present in that installation. There is no co-domain, and I'm using the same domain name as I'm previously using.

    I believe the problem lies in my Vhost file so here it is below:
    Code:
    ###################################
    #
    # ISPConfig vHost Configuration File
    #         Version 1.0
    #
    ###################################
    #
    NameVirtualHost 192.168.3.4:80
    <VirtualHost 192.168.3.4:80>
      ServerName localhost
      ServerAdmin root@localhost
      DocumentRoot /var/www/sharedip
      <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
        RewriteRule .* - [F]
      </IfModule>
    </VirtualHost>
    #
    #
    ######################################
    # Vhost: www.domain.ext:80
    ######################################
    #
    #
    <VirtualHost 192.168.3.4:80>
    SSLCertificateChainFile /var/www/web1/ssl/gd_intermediate_bundle.crt
    ServerName www.domain.ext:80
    ServerAdmin [email protected]
    DocumentRoot /var/www/web1/web
    ServerAlias domain.ext
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    ErrorLog /var/www/web1/log/error.log
    AddType application/x-httpd-php .php .php3 .php4 .php5
    <Files *.php>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>domain.ext
    <Files *.php3>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php4>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php5>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    php_admin_flag safe_mode Off
    Alias /error/ "/var/www/web1/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
      RewriteRule .* - [F]
    </IfModule>
    </VirtualHost>
    #
    <IfModule mod_ssl.c>
    <VirtualHost 192.168.3.4:443>
    SSLCertificateChainFile /var/www/web1/ssl/gd_intermediate_bundle.crt
    ServerName www.domain.ext:443
    ServerAdmin [email protected]
    DocumentRoot /var/www/web1/web
    ServerAlias domain.ext
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    ErrorLog /var/www/web1/log/error.log
    AddType application/x-httpd-php .php .php3 .php4 .php5
    <Files *.php>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php3>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php4>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php5>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    php_admin_flag safe_mode Off
    SSLEngine on
    SSLCertificateFile /var/www/web1/ssl/www.domain.ext.crt
    SSLCertificateKeyFile /var/www/web1/ssl/www.domain.ext.key
    Alias /error/ "/var/www/web1/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
      RewriteRule .* - [F]
    </IfModule>
    </VirtualHost>
    </IfModule>
    #
    #
    ######################################
    # Vhost: shop.domain.ext:80
    ######################################
    #
    #
    <VirtualHost 192.168.3.4:80>
    ServerName shop.domain.ext:80
    ServerAdmin [email protected]
    DocumentRoot /var/www/web2/web
    DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi index.pl index.jsp Default.htm default.htm
    Alias  /cgi-bin/ /var/www/web2/cgi-bin/
    AddHandler cgi-script .cgi
    AddHandler cgi-script .pl
    ErrorLog /var/www/web2/log/error.log
    AddType application/x-httpd-php .php .php3 .php4 .php5
    <Files *.php>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php3>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php4>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    <Files *.php5>
        SetOutputFilter PHP
        SetInputFilter PHP
    </Files>
    php_admin_flag safe_mode Off
    Alias /error/ "/var/www/web2/web/error/"
    ErrorDocument 400 /error/invalidSyntax.html
    ErrorDocument 401 /error/authorizationRequired.html
    ErrorDocument 403 /error/forbidden.html
    ErrorDocument 404 /error/fileNotFound.html
    ErrorDocument 405 /error/methodNotAllowed.html
    ErrorDocument 500 /error/internalServerError.html
    ErrorDocument 503 /error/overloaded.html
    AliasMatch ^/~([^/]+)(/(.*))? /var/www/web2/user/$1/web/$3
    AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web2/user/$1/web/$3
    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
      RewriteRule .* - [F]
    </IfModule>
    </VirtualHost>
    #
    #
    #
    Is it an issue with ServerAlias? As you can see from my Vhost file, I have an SSL certificate tied to the "www.domain.ext" but it's actually sym-linked to "domain.ext". Here's the ls of the ssl directory to explain.
    Code:
    drwxr-xr-x 3 user1      web1 4096 2008-10-06 14:59 .
    drwxr-xr-x 9 user1      web1 4096 2008-10-14 13:33 ..
    -rwxr-xr-x 1 user1      web1 4604 2008-08-28 20:42 gd_intermediate_bundle.crt
    -rw-r--r-- 1 user1      web1 1765 2008-08-28 20:42 domain.ext.crt
    -rw-r--r-- 1 user1      web1  802 2008-08-28 20:38 domain.ext.csr
    -r-------- 1 user1      web1  887 2008-10-06 15:00 domain.ext.key
    lrwxrwxrwx 1 root       root   16 2008-07-04 12:41 www.domain.ext.crt -> domain.ext.crt
    lrwxrwxrwx 1 root       root   16 2008-07-04 12:42 www.domain.ext.csr -> domain.ext.csr
    lrwxrwxrwx 1 root       root   16 2008-07-04 12:42 www.domain.ext.key -> domain.ext.key
    Here is what is in my "Apache Directives" box in ISPConfig:
    Code:
    SSLCertificateChainFile /var/www/web1/ssl/gd_intermediate_bundle.crt
    AllowOverride All
    +FollowSymLinks
    -MultiViews 
    
    Here is my .htaccess file for web1 ("domain.ext & www.domain.ext"), which is also exactly the same as I'm using for web2 ("shop.domain.ext"):
    Code:
    ############################################
    ## default index file
    
        DirectoryIndex index.php
    
    <IfModule mod_security.c>
    ###########################################
    # disable POST processing to not break multiple image upload
    
        SecFilterEngine Off
        SecFilterScanPOST Off
    </IfModule>
    
    <IfModule mod_deflate.c>
    
    ############################################
    ## enable apache served files compression
    ## http://developer.yahoo.com/performance/rules.html#gzip
    
        # Insert filter
        SetOutputFilter DEFLATE
    
        # Netscape 4.x has some problems...
        BrowserMatch ^Mozilla/4 gzip-only-text/html
    
        # Netscape 4.06-4.08 have some more problems
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
    
        # MSIE masquerades as Netscape, but it is fine
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        # Don't compress images
        SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
    
        # Make sure proxies don't deliver the wrong content
        Header append Vary User-Agent env=!dont-vary
    
    </IfModule>
    
    <IfModule mod_rewrite.c>
    
    ############################################
    ## enable rewrites
    
        RewriteEngine on
    
    ############################################
    ## you can put here your magento root folder
    ## path relative to web root
    
        RewriteBase /
    
    ############################################
    ## workaround for HTTP authorization
    ## in CGI environment
    
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    ############################################
    ## always send 404 on missing files in these folders
    
        RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
    
    ############################################
    ## never rewrite for existing files, directories and links
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-l
    
    ############################################
    ## rewrite everything else to index.php
    
        RewriteRule .* index.php [L]
    
    </IfModule>
    
    
    ############################################
    ## Prevent character encoding issues from server overrides
    ## If you still have problems, use the second line instead
    
        AddDefaultCharset Off
        #AddDefaultCharset UTF-8
    
    <IfModule mod_expires.c>
    
    ############################################
    ## Add default Expires header
    ## http://developer.yahoo.com/performance/rules.html#expires
    
        ExpiresDefault "access plus 1 year"
    
    </IfModule>
    
    ############################################
    ## By default allow all access
    
        Order allow,deny
        Allow from all
    
    ############################################
    ## If running in cluster environment, uncomment this
    ## http://developer.yahoo.com/performance/rules.html#etags
    
        #FileETag none
    
    
    Why do I not want a trailing slash at the end of product names (productname.html)? Because when magento runs sitemaps or RSS feeds, it does so without the trailing slash and when one clicks a link to go that link (link without the trailing /), it's automatically rewritten so that it has the trailing slash. The trailing slash breaks things like Google sitemap submission and google base submission.

    Please help!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    ISPVonfig is not adding that trailing slash. As you see there is no such rewrite rule in the Vhost configuration file.

    Please make sure that the recdirect field of the co-domain is empty.
     

Share This Page