A simple Windows Webserver for PHP and CGI Scripts

A simple Windows Webserver for PHP and CGI Scripts

.htaccess Files

The the newest versions of WWebserver understand .htaccess files, for URL rewriting and redirections like on Apache servers. Thats nice for deep links on Wordpress sites, error pages and SEO optimization.

.htaccess is enabled by default. You can disable it in cfg\speed.txt

# Enable / Disable .htaccess (mod_rewrite) support
htaccess_support=off

mod_rewrite

Note! This is not the mod_rewrite module from Apache, because of WWebserver ist not Apache.
The functionality was reprogrammed from mod_rewrite Apache documentation.
The following functions are not supported:

RewriteMap is not supported
RewriteOptions has no effect
RewriteCond tests -h, l, L, s, U, x are not supported
Placeholder %{SSL:variable} has no effect
RewriteRule flags CO, H are not supported
RewriteRule flags DPI, P, NS have no effects
RewriteRule flag B cannot have own character set

Redirection

WWebserver understand the following redirection directives from Apache:

Redirect and RedirectMatch

Read Apache mod_alias documentation.

Error Documents

You can define own error pages with directive ErrorDocument.

Read Apache custom error pages documentation.

Authorization

WWebserver understand AuthUserFile and AuthType directives.
Read more about directory protection.

 

FAQ

Wordpress does not understand my Pemalinks.

Because of Wordpress does not detect the original Apache Webserver the Permalinks are disabled and no .htaccess file is created automatically. Only the format index.php/linkname is allowed.
You have to copy the following .htaccess file manually into the root directory of Wordpress.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

After that you have to create a user defined Permalink format in Wordpress administration panel. Therefore you have to remove index.php/ from the Permalink format. For example: Change /index.php/%year%/%monthnum%/%postname%/ to /%year%/%monthnum%/%postname%/

How i can set own 404 error page?

ErrorDocument 404 /my_error_page.php

How i can force https:// protocol?

RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]

How i can force leading www. for domains?

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]

How i can remove ending slashes from virtual URI?

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]
RewriteRule . my_app.php [L]

How i can make a complete directory and all sub directories forbidden?

Note! You also can create a simple file with name forbidden in the directory instead creating .htaccess file with following content.

Redirect 403 /mydirectory

Another way to make a complete directory forbidden.

RewriteEngine on
RewriteRule ^(.*)$ - [R=403,L]

How i can make a permanent redirect?

Redirect permanent /from /to

Links

mod_rewrite examples from real world:

...back