Search

Well, that behaviour was intended by @designermonkey. But you are right that it might not be desirable.

Someone should really write an article of this. I always look up this thread when I want to redirect a custom given URL to a specific Symphony page (like Google's sitemap.xml in this example).

I intended that

\d{1,4}

would find a number from 1-9999 as this is correct regex. Using

[1-4]

would find a range of numbers between 1 and 4 only. My method was to allow for 9999 possible xml pages.

Also, Google doesn't care what your page is called, as long as it is a valid sitemap using the sitemaps.org protocol. I know this from experience (unless they've changed it in the last two weeks ;o) ).

I hear talk of making an htaccess class for Symphony to handle htaccess rewrites the same way the config is handled. It would be prudent to extens on this idea and make it possible to add them in the preferences page, so users can add their own, as well as extensions adding them.

I can't wait for that feature. I love me some regex!

I hear talk of making an htaccess class for Symphony to handle htaccess rewrites the same way the config is handled. It would be prudent to extens on this idea and make it possible to add them in the preferences page, so users can add their own, as well as extensions adding them.

That one is on my list. There is just so much left to do, and so little time..

I know the feeling!

If you'd like to display the site map on a website with a neat list style showing page names with links, you can modify the utility like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="no" />

    <xsl:template name="sitemap">
        <ul>
            <xsl:attribute name="xmlns">http://www.sitemaps.org/schemas/sitemap/0.9</xsl:attribute>
            <xsl:apply-templates select="/data/navigation/page[not(types/type = 'hidden') and not(types/type = 'admin')]" mode="sitemap" />
        </ul>
    </xsl:template>

    <xsl:template match="page" mode="sitemap">
        <xsl:param name="root" select="$root" />
        <xsl:variable name="url" select="concat($root, '/', @handle, '/')" />
        <li>
            <a href="{$url}"><xsl:value-of select="name" /></a>
        </li>
        <ul>
            <xsl:apply-templates select="page[not(types/type = 'hidden') and not(types/type = 'admin')]" mode="sitemap">
                <xsl:with-param name="root" select="concat($root, '/', @handle)" />
            </xsl:apply-templates>
        </ul>
    </xsl:template>

</xsl:stylesheet>

I have a small situation. Taking what kanduvisla said here I would like to add his rules

# Sitemap.xml redirect
RewriteCond $1 ^sitemap.xml
RewriteRule ^(.*)$ index.php?symphony-page=sitemapxml [L]

but for an installation that uses Language Redirect. This is my .htaccess:

### Symphony 2.2.x ###
Options +FollowSymlinks -Indexes

<IfModule mod_rewrite.c>

    RewriteEngine on
    RewriteBase /kangen/

    ### SECURITY - Protect crucial files
    RewriteRule ^manifest/(.*)$ - [F]
    RewriteRule ^workspace/utilities/(.*).xsl$ - [F]
    RewriteRule ^workspace/pages/(.*).xsl$ - [F]
    RewriteRule ^(.*).sql$ - [F]

    ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico"
    RewriteCond %{REQUEST_FILENAME} favicon.ico [NC]
    RewriteRule .* - [S=14]

    ### IMAGE RULES 
    RewriteRule ^image/(.+.(jpg|gif|jpeg|png|bmp))$ extensions/jit_image_manipulation/lib/image.php?param=$1 [L,NC]

    ### CHECK FOR TRAILING SLASH - Will ignore files
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !/$
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ $1/ [L,R=301]

    ### URL Correction
    RewriteRule ^(symphony/)?index.php(/.*/?) $1$2 [NC]

    ### ADMIN REWRITE
    RewriteRule ^symphony/?$ index.php?mode=administration&%{QUERY_STRING} [NC,L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^symphony(/(.*/?))?$ index.php?symphony-page=$1&mode=administration&%{QUERY_STRING}   [NC,L]

    ### LANGUAGE REDIRECT RULES start
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(ro|en)-?()?/(.*/?)$ index.php?language=$1&region=$2&symphony-page=$3&%{QUERY_STRING} [L]
    ### LANGUAGE REDIRECT RULES end

    ### FRONTEND REWRITE - Will ignore files and folders
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*/?)$ index.php?symphony-page=$1&%{QUERY_STRING}    [L]

</IfModule>

Do you have any idea where and how should I insert it? It must take notice of the language rules because I need them. Something like:

Default language is ro.

www.mysite.com/sitemap.xml -> www.mysite.com/ro/sitemapxml
www.mysite.com/en/sitemap.xml -> www.mysite.com/en/sitemapxml
www.mysite.com/ro/sitemap.xml -> www.mysite.com/ro/sitemapxml

You can copy rule from language redirect and put it modified before language redirect rules:

RewriteCond %{REQUEST_FILENAME} ^sitemap.xml$
RewriteRule ^(ro|en)-?()?/(.*/?)$ index.php?language=$1&region=$2&symphony-page=$3&%{QUERY_STRING} [L]

I did not test it, so it may be wrong ;).

Nope, doesn't work ...

Try this one:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} sitemap.xml$
RewriteRule ^((ro|en)(-(.{2}))?/|)(.*/?)$ index.php?language=$2&region=$4&symphony-page=sitemapxml&%{QUERY_STRING} [L]

It does redirect to sitemap by default (no language code), but does not setup language to ro then. You will have to set default param value in XSLT.

You can also use {$url-language:ro} in Data Source filters, to select default language if URL variable is not set.

Thank you, ahwayakchih, but it still didn't work.

I decided to simply use a Page with handle sitemapxml or whatever :)

EDIT

I decided to use a sitemap index and 2 pages.

In robots.txt I added the path to a Page representing sitemap index:

Sitemap: http://www.mysite.com/sitemap-index

sitemap-index Page generates the sitemaps for each language set by Language Redirect. It doesn't have the Language Redirect event attached.

<?xml version="1.0" encoding="UTF-8"?>
    <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <sitemap>
        <loc>http://www.mysite.com/ro/sitemap-xml</loc>
    </sitemap>
    <sitemap>
        <loc>http://www.mysite.com/en/sitemap-xml</loc>
    </sitemap>
    <sitemap>
        <loc>http://www.mysite.com/fr/sitemap-xml</loc>
    </sitemap>
</sitemapindex>

The sitemap-xml Page has the event attached and generates the localised sitemap according to sitemaps protocol.

Thank you, ahwayakchih, but it still didn't work.

It worked here, so i have no idea why it did not work there.

Just reading back over this thread and was thinking, does anyone use this approach to create a sort of dynamic .css file that can have configurable elements in a preferences page for a lightweight user? i.e defining colours and font-sizes a la Cremols ensemble preferences page maybe? or does that seem like bad practice?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details