Elements CMS - Pretty URLs

I’m currently trying to set up pretty URLs for my blog in RW Elements.
For that, I entered the following into my .htaccess file:

# Enable the rewrite engine
RewriteEngine On
RewriteBase /

# ----------------------------------------
# 1) Redirect old links to Pretty URL
# Example: /blog/post/?item=slug -> /blog/slug
RewriteCond %{QUERY_STRING} ^item=([^&]+)$
RewriteRule ^news/post/$ /news/%1? [R=301,L]

# ----------------------------------------
# 2) Internally rewrite Pretty URLs
# Example: /blog/slug -> /blog/post/?item=slug
RewriteRule ^news/([^/]+)/?$ news/post/?item=$1 [L,QSA]

Unfortunately, this hasn’t worked for me so far.
Has anyone successfully managed to use pretty URLs with Elements before?
Could someone give me a tip on what the correct .htaccess entry should look like?

1 Like

I have spent several days trying to transform the current Elements CMS blog slug into a meaningful structure, specifically into /blog/?item=my-blog-post.

I’ve tried numerous .htaccess entries, as well as changing the index.php in the post folder to post.php, similar to how it’s done with Total CMS, and made the corresponding .htaccess entries.

Unfortunately, all these attempts have failed.

@ben
Ideally, I would like to set up my blogs so that the ‘post’ folder does not always appear between my blog and the blog slug. How can I do this?

Hi @Pegasus

We will be supporting pretty urls in the following format: https://my-blog.com/post/post-slug

To achieve this you can add the following code to your htaccess file:

RewriteEngine On

# ----------------------------------------
# 1. Redirect /post/?item=slug and /post/index.php?item=slug → /post/slug
RewriteCond %{THE_REQUEST} \s/post/(index\.php)?\?item=([^&\s]+) [NC]
RewriteRule ^post/?$ /post/%2? [R=301,L]

# ----------------------------------------
# 2. Internally rewrite /post/slug → /post/index.php?item=slug
RewriteRule ^post/([^/]+)/?$ post/index.php?item=$1 [L,QSA]

You will then need to add the following “base” tag to the <head> area of your project’s template:

<base href="/">

<!-- OR if you're publishing to a subfolder: -->
<base href="/subfolder/">

This ensures that URL like /post/my-first-post is rewritten under the hood to /post/index.php?item=my-first-post.

Obviously “post” can be anything you want, you just need to ensure your update the htaccess code to match whatever you’ve called the folder in Elements.

We will have more detailed tutorials and documentation as the CMS matures, but I hope that helps for now :slight_smile:

1 Like

Thanks @ben. This is how it works with IIS.

Page Structure:

page Aktuelles:

Edit Extra Code:

example md-file:

---
title: "3 Welpen suchen ein Zuhause"
date: "2025-09-14 23:59"
tags: [D-Wurf]
categories: []
author: Ulrich
image:
    src: /cornrow_aushang_2025.jpg
    alt: CORNROW 3 Welpen suchen ein Zuhause
imagelinktarget:
imagelinktitle:
---

Drei süße Curly Coated Retriever-Welpen suchen ein liebevolles Zuhause!
Die kleinen Rüden sind am 27. Juni 2025 geboren, kerngesund, verspielt und bestens sozialisiert. Curly Coated Retriever sind wesensfeste, arbeitsfreudige und aktive Familienhunde, die sowohl Bewegung als auch Nähe zu ihren Menschen lieben.

Die Welpen wachsen bei uns im Garten auf, lernen verschiedene Umwelteinflüsse kennen und freuen sich immer über Besuch. Wenn Sie Interesse an einem aktiven, treuen Begleiter fürs Leben haben, melden Sie sich gerne und vereinbaren einen unverbindlichen Kennenlerntermin.

the web.config should be in the Item Template: (new version)

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>

        <!-- A) Redirect: index.php?item=slug → /slug -->
        <rule name="Redirect item→slug (local)" stopProcessing="true">
          <!-- In Ordner-web.config ist die URL relativ zum Ordner -->
          <match url="^(|index\.php)$" ignoreCase="true" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
            <!-- item=slug vorhanden -->
            <add input="{QUERY_STRING}" pattern="(?:^|&amp;)item=([^&amp;]+)" />
            <!-- nur GET/HEAD redirecten, um Form-POSTs nicht zu zerstören -->
            <add input="{REQUEST_METHOD}" pattern="^(GET|HEAD)$" />
          </conditions>
          <action type="Redirect"
                  url="{C:1}"
                  redirectType="Permanent"
                  appendQueryString="false" />
        </rule>

        <!-- B) Rewrite: /slug → index.php?item=slug -->
        <rule name="Rewrite slug→index (local)" stopProcessing="true">
          <!-- nur ein Segment (kein Slash) -->
          <match url="^([^/]+)/?$" ignoreCase="true" />
          <conditions logicalGrouping="MatchAll">
            <!-- Existierendes File/Ordner NICHT anfassen -->
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="index.php?item={R:1}" appendQueryString="true" />
        </rule>

      </rules>
    </rewrite>
  </system.webServer>
</configuration>

all links are:

{{item.url}}
1 Like

I tried setting it up with @ben’s configuration, but I just couldn’t get it to work — there’s always some kind of conflict.

Either the correct slug gets generated for the URL, or the layout breaks.

@ulrich

It looks like you’re running into the same issue. From what I can see, you’ve managed to get the slug routing working, but now the layout no longer works correctly for the post collection:

…and also not for the individual post layout:

For me, this means I’ll probably have to wait until there’s more information in the Elements CMS manual. And unless there’s a fix for this issue:

…running a blog just doesn’t make much sense for now.

I’ve fixed this issue. This is the corresponding .htaccess:

RewriteEngine On

# ------------------------------
# A) Redirect: index.php?item=slug → /slug
RewriteCond %{THE_REQUEST} \s/+[^?\s]*/?(index\.php)?\?item=([^&\s]+) [NC]
RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
RewriteRule ^(index\.php)?$ %2 [R=301,L]

# ------------------------------
# B) Rewrite: /slug → index.php?item=slug
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?item=$1 [L,QSA]

CSS JS … won’t changed

und ja, Du hast natürlich recht: Diese Einträge:

 <link rel="canonical" href="https://www.cornrow.de/artikel/" /> 
  <meta name="keywords" content="Artikel CORNROW Curly Coated Retriever Hunde Welpen Zucht" /> 
  <meta name="description" content="Artikel - CORNROW Curly Coated Retriever, gesunde, typische Hunde-Welpen aus liebevoller Zucht. Jetzt mehr über unsere Welpen erfahren!" /> 

müssen entsprechend umgesetzt werden. Nicht nur canonical auch keywords und description

I have already tried a few times to integrate CMS into my own website, but unfortunately I have failed every time.

This is a shame, because I have now completely moved away from RW classic and rebuilt my website from scratch using Elements. I think this has worked out quite well so far, but I still have to do without the blog posts, which are read quite frequently.

I have tried to transfer the structure of @Ben’s Appleseed News to my site, but it doesn’t seem to work (see screenshot).

I hope there will be good news on this very soon.

Looks like you need to change the page extension to be php, you can do this via the page settings:

YES! Totally wright!

Now I have to prove only all links to see some articles. :upside_down_face:

But I’m in a good hope …. :vulcan_salute:

1 Like

I am completely frustrated!!! Hope was one thing…

At first, I believed I would be able to make my blog posts visible again in Elements. Unfortunately, I was mistaken, and I am slowly starting to feel like a programmer. It’s a profession that is certainly interesting and exciting, but if I had to learn that too, my day would have to have 48 hours.

I’ve spent so many hours following Ben’s explanations, translating them each time and trying to understand them at the same time. I can imagine that the CMS system you’ve come up with has its advantages, but unfortunately it doesn’t help me.

I need a blog system where I can easily enter my posts so that I can then get back to my actual work.

I understood that this was coming, but now I’m not so sure if that’s true. Perhaps you could say something about this and also about a timeline. Can’t you just create a simple input system that works similarly to Alloy?

That would help me so much!

It is possible to create a form that uses a webhook to send data to a PHP script on your website, which then generates an MD file.

Important: MD files created in this way are not stored within the project or in the backup. Therefore, they must be downloaded manually from the website and saved separately.

Hi @Gelbseidenraupe

I completely understand your frustration, it’s never fun when things don’t work the way you hoped.

The CMS is still in its early stages, and there are definitely issues and limitations we’re actively working to improve. We’re releasing updates regularly with fixes and enhancements, so progress is being made week by week.

From what you’ve said, it sounds like you’re asking about an online editor for the CMS, something where you can log in via a browser and manage your content directly (add, edit, delete posts, etc.).

If that’s the case, I want to be upfront: we haven’t started development on the online editing interface yet, and I don’t want to give you a false sense of when it’ll be ready. It’s on our long-term roadmap, but it’s not something you should expect in the near future.

Thanks again for your patience, and if you have any questions or ideas in the meantime, we’re always happy to hear them :slight_smile:

2 Likes

Hi @ben

My frustration was not meant to be malicious, but sometimes you just need to get things off your chest. :smirking_face:

Nothing is worse than promises that, for whatever reason, cannot be kept.
Thank you for your openness! And work hard to make it happen! :blush:

We’ve been very up-front from the beginning. The Elements CMS is in BETA, it is still a work-in-progress.

We’ve not even released all the components for it yet. Ideally, you shouldn’t be using it in a production environment, and if you do you need to remember it’s a beta. We also specifically highlighted the fact that the online component will be a separate paid-for add-on at some point in the future.

I’m actually wondering if we should pull the CMS from Elements (for now until we’re further along). Due to its complexity it seems to require a high level of support and hand-holding. The CMS was never supposed to be part of the core product.

1 Like

Oh God, NO! I’ve already aligned all my projects with it.

Personally, I’ve found a good way to work with it. Even though it’s still limited, it works well enough for me. So PLEASE don’t roll back the CMS feature again.

3 Likes

@dan He is actually giving you a compliment for being realistic upfront :slight_smile: A kind of german way to say thank you and looking forward to the coming improvements.

3 Likes

@dan we germans are a bit special. sorry about that.

3 Likes

That‘s wright! :blush:

No reason for excuse!