We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36678
    • 152 Posts
    What should be my full .htaccess if I have subdomаin?
    Standard example is given in itself Plugin. I tried many variations and ....nothing sad (error 500). I have MODx 0.9.6.3 clear version(new install) with SEO strict 1.0.1.
    In System Events I have this:

    SEO Strict URLs - Plugin - System Events
    Error
    
    syntax error, unexpected '/'
    
    Parse error: syntax error, unexpected '/' in /home/acount/public_html/subdomain/manager/includes/document.parser.class.inc.php(745) : eval()'d code on line 1


    Any proposals?
      Multylingo 1.0 alpha (snippet + plugin) - For creation a full-featured multilingual site with MODx Evo
      My sites:
      Мисли, интересни мисли
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: sykrateno at Jan 20, 2009, 04:55 AM

      SEO Strict URLs - Plugin - System Events
      Error
      
      syntax error, unexpected '/'
      
      Parse error: syntax error, unexpected '/' in /home/acount/public_html/subdomain/manager/includes/document.parser.class.inc.php(745) : eval()'d code on line 1


      Any proposals?
      You need to fix the syntax error in the plugin first.
        • 36678
        • 152 Posts
        OpenGeek : You need to fix the syntax error in the plugin first.

        The plugin is standart huh I don`t know undecided
          Multylingo 1.0 alpha (snippet + plugin) - For creation a full-featured multilingual site with MODx Evo
          My sites:
          Мисли, интересни мисли
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: sykrateno at Jan 20, 2009, 10:12 AM

          OpenGeek : You need to fix the syntax error in the plugin first.

          The plugin is standart huh I don`t know undecided
          You must have copied and pasted it wrong huh , perhaps undecided
            • 36678
            • 152 Posts
            SEO Strict code
            //<?php
            // Strict URLs
            // version 1.0.1
            // Enforces the use of strict URLs to prevent duplicate content.
            // By Jeremy Luebke @ www.xuru.com
            // Contributions by Brian Stanback @ www.stanback.net
            
            // On Install: Check the "OnWebPageInit" & "OnWebPagePrerender" boxes in the System Events tab.
            // Plugin configuration: &editDocLinks=Edit document links;int;1 &makeFolders=Rewrite containers as folders;int;1 &emptyFolders=Check for empty container when rewriting;int;0 &override=Enable manual overrides;int;0 &overrideTV=Override TV name;string;seoOverride
            
            // For overriding documents, create a new template variabe (TV) named seoOverride with the following options:
            //    Input Type: DropDown List Menu
            //    Input Option Values: Disabled==-1||Base Name==0||Append Extension==1||Folder==2
            //    Default Value: -1
            
            //  # Include the following in your .htaccess file
            //  # Replace "example.com" &  "example\.com" with your domain info
            //  RewriteCond %{HTTP_HOST} .
            //  RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
            //  RewriteRule (.*) http://www.example.com/$1 [R=301,L] 
            
            // Begin plugin code
            $e = &$modx->event;
            
            if ($e->name == 'OnWebPageInit') 
            {
               $documentIdentifier = $modx->documentIdentifier;
            
               if ($documentIdentifier)  // Check for 404 error
               {
                  $myProtocol = ($_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
                  $s = $_SERVER['REQUEST_URI'];
                  $parts = explode("?", $s);  
            
                  $alias = $modx->aliasListing[$documentIdentifier]['alias'];
                  if ($makeFolders)
                  {
                     if ($emptyFolders)
                     {
                        $result = $modx->db->select('isfolder', $modx->getFullTableName('site_content'), 'id = ' . $documentIdentifier);
                        $isfolder = $modx->db->getValue($result);
                     }
                     else
                     {
                        $isfolder = (count($modx->getChildIds($documentIdentifier, 1)) > 0) ? 1 : 0;
                     }
                  }
            
                  if ($override && $overrideOption = $modx->getTemplateVarOutput($overrideTV, $documentIdentifier))
                  {
                     switch ($overrideOption[$overrideTV])
                     {
                        case 0:
                           $isoverride = 1;
                           break;
                        case 1:
                           $isfolder = 0;
                           break;
                        case 2:
                           $makeFolders = 1;
                           $isfolder = 1;
                     }
                  }
            
                  if ($isoverride)
                  {
                     $strictURL = preg_replace('/[^\/]+$/', $alias, $modx->makeUrl($documentIdentifier));
                  }
                  elseif ($isfolder && $makeFolders)
                  {
                     $strictURL = preg_replace('/[^\/]+$/', $alias, $modx->makeUrl($documentIdentifier)) . "/";
                  }
                  else
                  {
                     $strictURL = $modx->makeUrl($documentIdentifier);
                  }
            
                  $myDomain = $myProtocol . "://" . $_SERVER['HTTP_HOST'];
                  $newURL = $myDomain . $strictURL;
                  $requestedURL = $myDomain . $parts[0];
            
                  if ($documentIdentifier == $modx->config['site_start'])
                  {
                     if ($requestedURL != $modx->config['site_url'])
                     {
                        // Force redirect of site start
                        header("HTTP/1.1 301 Moved Permanently");
                        $qstring = preg_replace("#(^|&)(q|id)=[^&]+#", '', $parts[1]);  // Strip conflicting id/q from query string
                        if ($qstring) header('Location: ' . $modx->config['site_url'] . '?' . $qstring);
                        else header('Location: ' . $modx->config['site_url']);
                        exit(0);
                     }
                  }
                  elseif ($parts[0] != $strictURL)
                  {
                     // Force page redirect
                     header("HTTP/1.1 301 Moved Permanently");
                     $qstring = preg_replace("#(^|&)(q|id)=[^&]+#", '', $parts[1]);  // Strip conflicting id/q from query string
                     if ($qstring) header('Location: ' . $strictURL . '?' . $qstring);
                     else header('Location: ' . $strictURL);
                     exit(0);
                  }
               }
            }
            elseif ($e->name == 'OnWebPagePrerender')
            {
               if ($editDocLinks)
               {
                  $myDomain = $_SERVER['HTTP_HOST'];
                  $furlSuffix = $modx->config['friendly_url_suffix'];
                  $baseUrl = $modx->config['base_url'];
                  $o = &$modx->documentOutput; // get a reference of the output
            
                  // Reduce site start to base url
                  $overrideAlias = $modx->aliasListing[$modx->config['site_start']]['alias'];
                  $overridePath = $modx->aliasListing[$modx->config['site_start']]['path'];
                  $o = preg_replace("#((href|action)=\"|$myDomain)($baseUrl)?($overridePath/)?$overrideAlias$furlSuffix#", '${1}' . $baseUrl, $o);
            
                  if ($override)
                  {
                     // Replace manual override links
                     $sql = "SELECT tvc.contentid as id, tvc.value as value FROM " . $modx->getFullTableName('site_tmplvars') . " tv ";
                     $sql .= "INNER JOIN " . $modx->getFullTableName('site_tmplvar_templates') . " tvtpl ON tvtpl.tmplvarid = tv.id ";
                     $sql .= "LEFT JOIN " . $modx->getFullTableName('site_tmplvar_contentvalues') . " tvc ON tvc.tmplvarid = tv.id ";
                     $sql .= "LEFT JOIN " . $modx->getFullTableName('site_content') . " sc ON sc.id = tvc.contentid ";
                     $sql .= "WHERE sc.published = 1 AND tvtpl.templateid = sc.template AND tv.name = '$overrideTV'";
                     $results = $modx->dbQuery($sql);
                     while ($row = $modx->fetchRow($results))
                     {
                        $overrideAlias = $modx->aliasListing[$row['id']]['alias'];
                        $overridePath = $modx->aliasListing[$row['id']]['path'];
                        switch ($row['value'])
                        {
                           case 0:
                              $o = preg_replace("#((href|action)=\"($baseUrl)?($overridePath/)?|$myDomain$baseUrl$overridePath/?)$overrideAlias$furlSuffix#", '${1}' . $overrideAlias, $o);
                              break;
                           case 2:
                              $o = preg_replace("#((href|action)=\"($baseUrl)?($overridePath/)?|$myDomain$baseUrl$overridePath/?)$overrideAlias$furlSuffix/?#", '${1}' . rtrim($overrideAlias, '/') . '/', $o);
                              break;
                        }
                     }
                  }
            
                  if ($makeFolders)
                  {
                     if ($emptyFolders)
                     {
                        // Populate isfolder array
                        $isfolder_arr = array();
                        $result = $modx->db->select('id', $modx->getFullTableName('site_content'), 'published > 0 AND isfolder > 0');
                        while ($row = $modx->db->getRow($result))
                           $isfolder_arr[$row['id']] = true;
                     }
            
                     // Replace container links
                     foreach ($modx->documentListing as $id)
                     {
                        if ((is_array($isfolder_arr) && isset($isfolder_arr[$id])) || count($modx->getChildIds($id, 1)))
                        {
                           $overrideAlias = $modx->aliasListing[$id]['alias'];
                           $overridePath = $modx->aliasListing[$id]['path'];
                           $o = preg_replace("#((href|action)=\"($baseUrl)?($overridePath/)?|$myDomain$baseUrl$overridePath/?)$overrideAlias$furlSuffix/?#", '${1}' . rtrim($overrideAlias, '/') . '/', $o);
                        }
                     }
                  }
               }
            }

            Plugin config:
            &editDocLinks=Edit document links;int;1 &makeFolders=Rewrite containers as folders;int;1 &emptyFolders=Check for empty container when rewriting;int;0 &override=Enable manual overrides;int;0 &overrideTV=Override TV name;string;seoOverride


            Check OnWebPageInit and OnWebPagePrerender

            Use friendly URLs: yes
            Use friendly aliases: yes
            Use friendly alias path: no
            Allow duplicate aliases: no
            Automatically generate alias: no

            In my domain all is perfect.
              Multylingo 1.0 alpha (snippet + plugin) - For creation a full-featured multilingual site with MODx Evo
              My sites:
              Мисли, интересни мисли
              • 37550 ☆ A M B ☆
              • 711 Posts
              Have you tried taking out //<?php

                http://www.onesmarthost.co.uk
                UK MODX Hosting with love.
                • 36678
                • 152 Posts
                Already. Nothing different.
                Here is my .htaccess (now) maybe here is mistake (
                I tried and options shown in the example in SEO strict code, but free interpretations rather):
                #Options +FollowSymlinks
                RewriteEngine On
                RewriteBase /subdomain
                
                # Fix Apache internal dummy connections from breaking [(site_url)] cache
                RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
                RewriteRule .* - [F,L]
                
                # The Friendly URLs part
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ /subdomain/index.php?q=$1 [L,QSA]

                P.S. At least no longer pull in error in System Events. I am puzzled. The code is same.
                P.S.S. Like directory (site.com/subdomain) work, like subdomain (subdomain.site.com) No

                  Multylingo 1.0 alpha (snippet + plugin) - For creation a full-featured multilingual site with MODx Evo
                  My sites:
                  Мисли, интересни мисли
                  • 36678
                  • 152 Posts
                  I did it. Many thanks to all who respond to help. Will make a unique visit to the sites and if there is some ad clicks will not overact though.

                  Тhe problem is:
                  RewriteRule ^(.*)$ /subdomain/index.php?q=$1 [L,QSA]
                  10x
                    Multylingo 1.0 alpha (snippet + plugin) - For creation a full-featured multilingual site with MODx Evo
                    My sites:
                    Мисли, интересни мисли