15.4. Konfigurationsbeispiele

15.4.1. Betrieb mit einem Projekt

Für den Betrieb mit nur einem einzelnen Projekt ist es nicht nötig, den Projektnamen in den URLs mitzuliefern. Darum kann man ihn weglassen, was entsprechend kürzere URLs erlaubt. Das erste Listing zeigt die dazu passende URL-Konfiguration für Welcompose. Das zweite Listing hält die passenden Rewrite Rules für Apache bereit.

Um die URL-Konfiguration für Welcompose in Betrieb zu nehmen, brauchen Sie diese nur in die Datei core/conf/sys.inc.php anstelle der alten Konfiguration zu kopieren und die Domain example.tld durch Ihren eigenen zu ersetzen. Sollten Sie Welcompose in einem Unterverzeichnis installiert haben, müssen Sie dieses auch noch einfügen.

[Anmerkung] Anmerkung

Das Listing der URL-Konfiguration sowie die RewriteRules der .htaccess-Datei beziehen sich immer auf die jeweils aktuelle Version von Welcompose (Aktuell: 0.9.6).

[urls]
blog_index = "http://example.tld/page/<page_name>/"
blog_index_tag = "http://example.tld/page/<page_name>/tag/<tag_word>/"
blog_index_pager = "http://example.tld/page/<page_name>/offset/<start>/"
blog_index_tag_pager = "http://example.tld/page/<page_name>/tag/<tag_word>/offset/<start>/"
blog_index_start = "http://example.tld/"
blog_index_start_tag = "http://example.tld/tag/<tag_word>/"
blog_index_start_pager = "http://example.tld/offset/<start>/"
blog_index_start_tag_pager = "http://example.tld/tag/<tag_word>/offset/<start>/"
blog_atom_10 = "http://example.tld/page/<page_name>/Atom10/"
blog_atom_10_tag = "http://example.tld/page/<page_name>/Atom10/tag/<tag_word>/"
blog_atom_10_start = "http://example.tld/Atom10/"
blog_atom_10_start_tag = "http://example.tld/Atom10/tag/<tag_word>/"
blog_rss_20 = "http://example.tld/page/<page_name>/Rss20/"
blog_rss_20_tag = "http://example.tld/page/<page_name>/Rss20/tag/<tag_word>/"
blog_rss_20_start = "http://example.tld/Rss20/"
blog_rss_20_start_tag = "http://example.tld/Rss20/tag/<tag_word>/"
blog_comments_atom_10 = "http://example.tld/page/<page_name>/CommentsAtom10/"
blog_comments_atom_10_start = "http://example.tld/CommentsAtom10/"
blog_comments_rss_20 = "http://example.tld/page/<page_name>/CommentsRss20/"
blog_comments_rss_20_start = "http://example.tld/CommentsRss20/"
blog_item = "http://example.tld/page/<page_name>/<posting_year_added>/<posting_month_added>/<posting_day_added>/<posting_title>/"
blog_item_start = "http://example.tld/<posting_year_added>/<posting_month_added>/<posting_day_added>/<posting_title>/"
blog_archive_year = "http://example.tld/page/<page_name>/<posting_year_added>/"
blog_archive_year_pager = "http://example.tld/page/<page_name>/<posting_year_added>/offset/<start>"
blog_archive_year_start = "http://example.tld/<posting_year_added>/"
blog_archive_year_start_pager = "http://example.tld/<posting_year_added>/offset/<start>/"
blog_archive_month = "http://example.tld/page/<page_name>/<posting_year_added>/<posting_month_added>/"
blog_archive_month_pager = "http://example.tld/page/<page_name>/<posting_year_added>/<posting_month_added>/offset/<start>/"
blog_archive_month_start = "http://example.tld/<posting_year_added>/<posting_month_added>/"
blog_archive_month_start_pager = "http://example.tld/<posting_year_added>/<posting_month_added>/offset/<start>/"
event_index = "http://example.tld/page/<page_name>/"
event_index_tag = "http://example.tld/page/<page_name>/tag/<tag_word>/"
event_index_pager = "http://example.tld/page/<page_name>/offset/<start>/"
event_index_tag_pager = "http://example.tld/page/<page_name>/tag/<tag_word>/offset/<start>/"
event_index_start = "http://example.tld/"
event_index_start_tag = "http://example.tld/tag/<tag_word>/"
event_index_start_pager = "http://example.tld/offset/<start>/"
event_index_start_tag_pager = "http://example.tld/tag/<tag_word>/offset/<start>/"
event_atom_10 = "http://example.tld/page/<page_name>/Atom10/"
event_atom_10_tag = "http://example.tld/page/<page_name>/Atom10/tag/<tag_word>/"
event_atom_10_start = "http://example.tld/Atom10/"
event_atom_10_start_tag = "http://example.tld/Atom10/tag/<tag_word>/"
event_rss_20 = "http://example.tld/page/<page_name>/Rss20/"
event_rss_20_tag = "http://example.tld/page/<page_name>/Rss20/tag/<tag_word>/"
event_rss_20_start = "http://example.tld/Rss20/"
event_rss_20_start_tag = "http://example.tld/Rss20/tag/<tag_word>/"
generator_form_index = "http://example.tld/page/<page_name>/"
generator_form_index_start = "http://example.tld/"
global_template_url = "http://example.tld/gtpls/<global_template_name>"
global_template_url_start = "http://example.tld/gtpls/<global_template_name>"
simple_date_index = "http://example.tld/page/<page_name>/"
simple_date_index_pager = "http://example.tld/page/<page_name>/offset/<start>/"
simple_date_index_start = "http://example.tld/"
simple_date_index_start_pager = "http://example.tld/offset/<start>/"
simple_date_atom_10 = "http://example.tld/page/<page_name>/Atom10/"
simple_date_atom_10_start = "http://example.tld/Atom10/"
simple_date_rss_20 = "http://example.tld/page/<page_name>/Rss20/"
simple_date_rss_20_start = "http://example.tld/Rss20/"
simple_form_index = "http://example.tld/page/<page_name>/"
simple_form_index_start = "http://example.tld/"
simple_guestbook_index = "http://example.tld/page/<page_name>/"
simple_guestbook_index_pager = "http://example.tld/page/<page_name>/offset/<start>/"
simple_guestbook_index_start = "http://example.tld/"
simple_guestbook_index_start_pager = "http://example.tld/offset/<start>/"
simple_page_index = "http://example.tld/page/<page_name>/"
simple_page_index_start = "http://example.tld/"

Die nachfolgenden Rewrite Rules müssen in eine .htaccess-Datei im Welcompose-Installationsverzeichnis kopiert werden. Löschen Sie vorab alle anderen vorhandenen Rewrite Rules, um Wechselwirkungen zu vermeiden.

## Usage Howto
##
## - Create .htaccess file in root of welcompose installation.
## - Use Search & Replace of your editor to replace the-url-name-of-the-project
##   with the url name of your project.
## - If you installed welcompose to a subdirectory of your domain, prefix all paths
##   with the directory name.
## - If you don't like the path layout /page/<page_name>/, use Search & Replace of
##   your editor and replace it with something different. Rules: Avoid numbers
##   (will cause naming clash with blogs as root node), avoid names of existing
##   directories in the install dir (like admin, files and so on) and avoid the
##   reserved words offset, gtpls and all action names of welcompose like Rss20
##   Atom10, Index, ArchiveYear (all case insensitive).

RewriteEngine On

RewriteCond     %{REQUEST_URI}  ^/gtpls/([a-z0-9\,\_\.\s\-]+)$
RewriteRule     ^               /global_template.php?project_name=the-url-name-of-the-project&name=%1

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=Index&page_name=%1

# blog in root
RewriteCond     %{REQUEST_URI}  ^/offset/([0-9]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=Index&start=%1

RewriteCond     %{REQUEST_URI}  ^/tag/([a-z0-9\-]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=Index&tag=%1

RewriteCond     %{REQUEST_URI}  ^/tag/([a-z0-9\-]+)/offset/([0-9]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=Index&tag=%1&start=%2

RewriteCond     %{REQUEST_URI}  ^/([0-9]+)/([0-9]+)/([0-9]+)/([a-z0-9\_\.\-]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=Item&posting_year_added=%1&posting_month_added=%2&posting_day_added=%3&posting_title=%4

RewriteCond     %{REQUEST_URI}  ^/([0-9]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=ArchiveYear&posting_year_added=%1&

RewriteCond     %{REQUEST_URI}  ^/([0-9]+)/([0-9]+)(/offset/([0-9]+))?(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=ArchiveMonth&posting_year_added=%1&posting_month_added=%2&start=%4

RewriteCond     %{REQUEST_URI}  ^/(Rss20|Atom10|CommentsRss20|CommentsAtom10)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=%1

RewriteCond     %{REQUEST_URI}  ^/(Rss20|Atom10|CommentsRss20|CommentsAtom10)/tag/([a-z0-9\-]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=%1&tag=%2

# blog in tree
RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/offset/([0-9]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=Index&start=%2

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/tag/([a-z0-9\-]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=Index&tag=%2

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/tag/([a-z0-9\-]+)/offset/([0-9]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=Index&tag=%2&start=%3

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/([0-9]+)/([0-9]+)/([0-9]+)/([a-z0-9\_\.\-]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=Item&posting_year_added=%2&posting_month_added=%3&posting_day_added=%4&posting_title=%5

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/([0-9]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=ArchiveYear&posting_year_added=%2

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/([0-9]+)/([0-9]+)(/offset/([0-9]+))?(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=ArchiveMonth&posting_year_added=%2&posting_month_added=%3&start=%5

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/(Rss20|Atom10|CommentsRss20|CommentsAtom10)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=%2

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/(Rss20|Atom10|CommentsRss20|CommentsAtom10)/tag/([a-z0-9\-]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=%2&tag=%3

Alle Vorkommen des Projektnamen (project_name=the-url-name-of-the-project&) können entweder komplett entfernt oder mit dem jeweiligen Projektnamen ersetzt werden. Achten Sie darauf, dass Sie den URL-Namen des Projekts verwenden.

Sollten Sie Welcompose in einem Unterverzeichnis installiert haben, müssen die Rewrite Rules jeweils um den Namen des Unterverzeichnisses erweitert werden. Wenn Ihr Unterverzeichnis beispielsweise cms/ heisst, müssen die Pfade in

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&action=Index&page_name=%1

mit cms/ erweitert werden, was zu folgendem Resultat führt:

RewriteCond     %{REQUEST_URI}  ^/cms/page/([a-z0-9\-]+)(/?)$
RewriteRule     ^               /cms/index.php?project_name=the-url-name-of-the-project&action=Index&page_name=%1

Wiederholen Sie dies für alle anderen Rewrite Rules.

Möchten Sie weitere Änderungen am Pfadlayout vornehmen, weil Ihnen beispielsweise englische Wörter wie page in den URLs nicht gefallen, ist das selbstverständlich möglich. Allerdings muss dabei darauf geachtet werden, dass die URLs nicht mit real existierenden Verzeichnissen respektive Dateien kollidieren.

Sollen Änderungen an den Namen der Actions vorgenommen werden, müssen die Rewrite URLs umgeschrieben werden, bei denen die Action direkt aus den URLs übernommen wird. Wenn man beispielsweise bei

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/(Rss20|Atom10|CommentsRss20|CommentsAtom10)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=%2

statt CommentsRss20 und CommentsAtom10 lieber KommentareRss20 respektive KommentareAtom10 schreiben möchte, muss man aus dieser Rewrite Rule mindestens zwei verschiedene machen:

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/(Rss20|Atom10)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=%2

RewriteCond     %{REQUEST_URI}  ^/page/([a-z0-9\-]+)/Kommentare(Rss20|Atom10)(/?)$
RewriteRule     ^               /index.php?project_name=the-url-name-of-the-project&page_name=%1&action=Comments%2