Forum Moderators: phranque
Well I've searched your topics for the appropriate information and I've found some information, namely in the topic at this topic [webmasterworld.com].
However, for some reason I get an 500-error when I enter a subdomain. This is my current .htaccess, with some rules left out because it's a huge file.
Can someone please help me out?
# Errorpagina
ErrorDocument 401 etc. etc.# PHP Variabelen
php_value etc. etc.
# S2M3
RewriteRule ^m$ http://www.example.com/v3/m [L,NC]
RewriteRule ^m/(.*)$ http://www.example.com/v3/m/$1 [L,NC]
##############################################################################################
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
# Voorkom bekijken htaccess
<Files .htaccess>
order allow,deny
deny from all
</Files>
#voorkom example.com
rewritecond %{http_host} ^example\.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]
# Rewrite <subdomain>.example.com/<path> to example.com/<subdomain>/<path>
#
# Skip rewrite if no hostname or if subdomain is www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
# Extract (required) subdomain (%1), and first path element (%3), discard port number if present (%2)
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+)\.example\.nl(:80)?<>/([^/]*) [NC]
# Rewrite only when subdomain not equal to first path element (prevents mod_rewrite recursion)
RewriteCond %1<>%3!^(.*)<>\1$ [NC]
# Rewrite to /subdomain/path
RewriteRule ^(.*) /%1/$1 [L]
##############################################################################################
# Aliasses
## Weblogs
RewriteRule ^blog/(.+)/?$ http://www.example.com/weblog/$1 [L,NC]
[about 100 lines]
# Paginas als www.ralphje.nl/hoi -> www.ralphje.nl/hoi.php als map hoi niet bestaat én bestand hoi niet bestaat
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ $1.php?action=$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([A-Za-z0-9-]+)/?$ $1.php
###
# Catching everything uncatched
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php !-f
RewriteRule ^([A-Za-z0-9-]+)/?$ http://www.example.com/weblog/$1 [L,NC]
# Dit is bovendien de fix voor de paginanummering
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php !-f
RewriteRule ^([A-Za-z0-9-]+)/(.+)/?$ http://www.example.com/weblog/$1/$2 [L,NC]
[edited by: jdMorgan at 12:09 am (utc) on Nov. 13, 2007]
[edit reason] Example.com. Please see Terms of Service. [/edit]
Also, please confirm that your operating system supports POSIX 1003.2 regular expressions -- This is required in order to use the back-reference method shown here. (Also note that because of this, the code has limited portability across server operating systms, which may be a concern if you need to change hosting platforms in the future).
Jim
# Rewrite <subdomain>.example.com/<path> to example.com/weblog/<subdomain>/<path>
#
# Rewrite only if not already rewritten to /weblog/
RewriteCond $1 !weblog/
# Skip rewrite if subdomain is www
RewriteCond %{HTTP_HOST} !^www\. [NC]
# Extract (required) subdomain to %1
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.nl(:80)?$
# Rewrite to /weblog/subdomain/URL-path
RewriteRule (.*) /weblog/%1/$1 [L]