# dlang.org .htaccess file (local Apache configuration)

# Enable mod_rewrite
RewriteEngine On

# Indicate that this directory maps to the root
# directory of the domain.
RewriteBase /

# Phobos rewrites:

# Package files are now generated to std_foo.html
# instead of std_foo_package.html. This change was
# done to preserve the links to std.algorithm,
# std.range etc. after they were split into packages.
# However, we need redirects for packages in
# previous stable releases (namely, std.container).

RewriteRule ^(phobos(-prerelease)?/std_container)_package\.html $1.html [R=301,L]

Redirect 301 /COM.html http://wiki.dlang.org/COM_Programming
Redirect 301 /dll.html http://wiki.dlang.org/Win32_DLLs_in_D
Redirect 301 /htomodule.html http://wiki.dlang.org/Converting_C_.h_Files_to_D_Modules
Redirect 301 /memory.html http://wiki.dlang.org/Memory_Management
Redirect 301 /windows.html http://wiki.dlang.org/D_for_Win32
Redirect 301 /getstarted.html http://wiki.dlang.org/Getting_Started
Redirect 301 /tools.html http://wiki.dlang.org/Development_tools

RewriteRule ^changelog(.html)?$ changelog/index.html [R=301,L]

# OS detection for CLI manual
RewriteCond %{HTTP_USER_AGENT} Windows
RewriteRule ^dmd.html dmd-windows.html [R]

RewriteCond %{HTTP_USER_AGENT} Mac
RewriteRule ^dmd.html dmd-osx.html [R]

RewriteCond %{HTTP_USER_AGENT} Linux
RewriteRule ^dmd.html dmd-linux.html [R]

RewriteCond %{HTTP_USER_AGENT} FreeBSD
RewriteRule ^dmd.html dmd-freebsd.html [R]

# soft-fail to windows
RewriteRule ^dmd.html dmd-windows.html [L,R]

# legacy URLs of /spec/ pages
RewriteRule ^(spec|intro|lex|grammar|module|declaration|type|property|\
attribute|pragma|expression|statement|arrays|hash-map|struct|class|interface|\
enum|const3|function|operatoroverloading|template|template-mixin|contracts|\
version|traits|errors|unittest|garbage|float|iasm|ddoc|interfaceToC|\
cpp_interface|objc_interface|portability|entity|memory-safe-d|abi|simd)\
(\.html)?$ \
spec/$1.html [R=301,L]

# Error pages
ErrorDocument 404 /404.html
