Documentation

Light-weight, fast, simple and powerful!
Share This
Translations of this page?:

Removing the question mark from the url

The default installation of Wolf CMS generates a question mark in the URLs it generates. This is for compatibility purposes, so Wolf CMS will run on almost any HTTP server by default.

However, most people (and search engines) don't really like this question mark. You can disable/remove the question mark after you installed Wolf CMS.

By default, Wolf CMS supports Apache. Other HTTP servers are supported based on user input.

Updated to reflect Wolf CMS 0.6.0

You must carry out both the “General actions” and the additional instructions for your specific webserver (Apache, Lighttpd, etc.).

General actions

The following actions should always be executed in order for Wolf CMS to use clean urls.

  1. Temporarily add write permissions to the config.php file.1)
  2. Edit the config.php file
  3. Change the value of “USE_MOD_REWRITE” to “true”.
  4. Save the config.php file.
  5. Remove the write permissions from the config.php file. Don't forget or skip this step!2)
  6. Apply the directions for your specific HTTP server. See below.
  7. After applying the directions, test out the change by going to the root of your website. You should no longer see the question mark.

Apache HTTP server actions

  1. Edit the _.htaccess file located in the Wolf CMS root directory.
  2. Find the line starting with RewriteBase /wolfcms/.
    If Wolf CMS lives in the root of your site3), delete the “wolfcms/” part so the line equals: RewriteBase /.
    If Wolf CMS lives in a subdirectory of your site4), change the ”/wolfcms/” part so the line equals: RewriteBase /mywolf/.
  3. Save the _.htaccess file.
  4. Rename the _.htaccess file into .htaccess (i.e. remove the underscore).

Lighttpd server actions

The paths used in the rewrite code below assume that your Wolf CMS installation lives at the root of the site, i.e. http://www.example.com.

Since Lighttpd does not have an equivalent of Apache's RewriteBase command, you will have to manually alter the paths below to conform to your Wolf CMS root.

# 
# Wolf CMS mod_rewrite rules for lighttpd
#
# If your Wolf CMS install lives in a sub-directory like: http://www.example.com/mywolf/
# you should add the subdirectory between ^ and / in the rules below and in the
replacement
# value, for example: "^/mywolf/admin(.*)$" => "/mywolf/admin/index.php?$1",
#
url.rewrite-once = (

    "^/install/index.html$" => "/install/index.php?rewrite=1",
    "^/install/index.php$" => "/install/index.php?rewrite=1",
    "^/install/$" => "/install/index.php?rewrite=1",
    "^/install/(.*)$" => "/install/$1",

    "^/admin/(images|javascripts|stylesheets|themes)/(.*)" => "/admin/$1/$2",
    "^/admin/index.php\?(.*)$" => "/admin/index.php?$1",
    "^/admin(.*)$" => "/admin/index.php?$1",

    "^/favicon\.ico$" => "$0",
    "^/(public|wolf)/(.*)$" => "/$1/$2",

    "^(?:(?!/admin/))/([^?]*)(\?(.*))$" => "/index.php?WOLFPAGE=$1&$2",
    "^/(.*)$" => "/index.php?WOLFPAGE=$1"

)

If you are using Wolf CMS 0.7.x, the location of some of the pages has changed. You will need to use the following instead. Since this uses url.rewrite-if-not-file, you will need at least version 1.4.24 of lighttpd.

url.rewrite-once = (

    "^/wolf/install/index.html$" => "/wolf/install/index.php?rewrite=1",
    "^/wolf/install/index.php$" => "/wolf/install/index.php?rewrite=1",
    "^/wolf/install/$" => "/wolf/install/index.php?rewrite=1",
    "^/wolf/install/(.*)$" => "/wolf/install/$1",
)

url.rewrite-if-not-file = (
    "^/([^\?]+)(\?(.*)$)?" => "/index.php?WOLFPAGE=$1&$3"
)

Hiawatha server actions

The paths used in the rewrite code below assume that your Wolf CMS installation lives in a “site” directory below the root of the system, i.e. http://www.example.com/site.

Since Hiawatha does not have an equivalent of Apache's RewriteBase command, you will have to manually alter the paths below to conform to your Wolf CMS root.

You will need an UrlToolkit similar to this where 'site' is the folder in the web root where Wolf CMS is unpacked.

UrlToolkit {
    ToolkitID = wolfcms
    Match ^/site/install/index.html$ Rewrite /site/install/index.php?rewrite=1
    Match ^/site/install/index.php$ Rewrite /site/install/index.php?rewrite=1
    Match ^/site/install/$ Rewrite /site/install/index.php?rewrite=1
    RequestURI exists Return
    Match ^/site/admin(.*)$ Rewrite /site/admin/index.php?$1
    Match ^/site(.*)$ Rewrite /site/index.php?WOLFPAGE=$1
}

Remember to enable this toolkit in your Virtual Host.

The 3 regex above RequestURI are used for clean url validation during installation only. They must be above RequestURI and can be commented out after installation.

You must have PreventSQLi disabled (is also the default I think).

Nginx server actions

The paths used in the rewrite code below assume that your Wolf CMS installation lives at the root of the site, i.e. http://www.example.com.

Since Nginx does not have an equivalent of Apache's RewriteBase command, you will have to manually alter the paths below to conform to your Wolf CMS root.

Put this in your server block:

if (!-e $request_filename) {
    rewrite  ^/(.*)$ /index.php?WOLFPAGE=$1  last;
    break;
}

You may also have to set the URL suffix to be blank

define('URL_SUFFIX', '');

in config.php

Zeus server actions

map path into SCRATCH:path from %{URL}           
look for file at %{SCRATCH:path}           
if exists then goto END           
look for dir at %{SCRATCH:path}           
if exists then goto END           

match URL into $ with ^/(.*)$
if matched
    look for file at $1
    if not exists
        set URL=/index.php?WOLFPAGE=$1
        goto END
    endif
endif
1) In Unix/Linux: chmod 666 config.php
2) In Unix/Linux: chmod 444 config.php
3) For example: www.mypage.com
4) For example: www.mypage.com/mywolf
 
removing_the_question_mark_from_the_url.txt · Last modified: 2011-09-27 20:41 by Fortron
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 wolfcms.org / design by yello studio / Wolf CMS Inside