Forum Moderators: phranque
RewriteEngine on
RewriteBase /
Options -MultiViews
RewriteCond %{HTTP_HOST}!^www\.domain\.nl [NC]
RewriteRule (.*) [domain.nl...] [R=301,L]
# Archiefmappen
RewriteRule ^([0-9]+)$ /$1/ [R=302]
RewriteRule ^([0-9]+)/$ /do.php?page=$1 [L]
# Categoriemappen
RewriteRule ^([a-z]+)/([a-z]+)$ /$1/$2/ [R=302]
RewriteRule ^([a-z]+)/([a-z]+)/$ /domap.php?map1=$1&map2=$2 [L]
RewriteRule ^([a-z]+)$ /$1/ [R=302]
RewriteRule ^([a-z]+)/$ /domap.php?map1=$1 [L]
Now i want to be able to have subdomain's. The subdomain's must not have the other reqriterules that are listed but thay must always redirect to a slash as now. They must have own redirects; for example [a-z] to /domap-subdomain.php?map1=...
RewriteEngine on
RewriteBase /
Options -MultiViews
# If no-www domain requested, externally redirect to www domain
RewriteCond %{HTTP_HOST} ^domain\.nl
RewriteRule (.*) [domain.nl...] [R=301,L]
# If www+subdomain domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
# If subdomain+www domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
# 0..9 maps rewrite
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteRule ^([0-9]+)$ /$1/ [R=302]
RewriteRule ^([0-9]+)/$ /do.php?page=$1 [L]
# two maps rewrite
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)$ /$1/$2/ [R=302]
RewriteRule ^([a-z]+)/([a-z]+)/$ /domap.php?map1=$1&map2=$2 [L]
# one map reqrite
RewriteRule ^([a-z]+)$ /$1/ [R=302]
RewriteRule ^([a-z]+)/$ /domap.php?map1=$1 [L]
# we got subdomain
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule (.*) /sd_%1/$1 [L]
I have:
RewriteEngine on
RewriteBase /
Options -MultiViews
# If no-www domain requested, externally redirect to www domain
RewriteCond %{HTTP_HOST} ^domain\.nl
RewriteRule (.*) [domain.nl...] [R=301,L]
# If www+subdomain domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
# If subdomain+www domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
# 0..9
# RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteRule ^([0-9]+)$ /$1/ [R=302]
RewriteRule ^([0-9]+)/$ /do.php?page=$1 [L]
# Maps
RewriteRule ^([a-z]+)/([a-z]+)$ /$1/$2/ [R=302]
RewriteRule ^([a-z]+)/([a-z]+)/$ /domap.php?map1=$1&map2=$2 [L]
RewriteRule ^([a-z]+)$ /$1/ [R=302]
RewriteRule ^([a-z]+)/$ /domap.php?map1=$1 [L]
# Subdomain
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule (.*) /sd_%1/$1 [L]
# 0..9 maps rewrite
RewriteCond %{HTTP_HOST} !^www\.domain\.nl
RewriteRule ^([0-9]+)$ http://%{HTTP_HOST}/$1/ [R=301,L]
#
RewriteCond %{HTTP_HOST} !^www\.domain\.nl
RewriteRule ^([0-9]+)/$ /do.php?page=$1 [L]
Jim
I have this now:
RewriteEngine on
RewriteBase /
Options -MultiViews
# If no-www domain requested, externally redirect to www domain
RewriteCond %{HTTP_HOST} ^domain\.nl
RewriteRule (.*) [domain.nl...] [R=301,L]
# If www+subdomain domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
# If subdomain+www domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
# 0..9
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteRule ^([0-9]+)$ [domain.nl...] [R=302]
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteRule ^([0-9]+)/$ /do.php?page=$1 [L]
# Maps
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)$ [domain.nl...] [R=302]
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)/$ /domap.php?map1=$1&map2=$2 [L]
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteRule ^([a-z]+)$ [domain.nl...] [R=302]
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteRule ^([a-z]+)/$ /domap.php?map1=$1 [L]
# Subdomain
#RewriteCond %{HTTP_HOST}!^www\.domain\.nl
#R#ewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
#RewriteRule (.*) /sd_%1/$1 [L]
The problem is in the subdomain. I want this to happen:
[domain.nl...] --> [domain.nl...]
[domain.nl...] --> [domain.nl...]
[domain.nl...] --> [domain.nl...]
[domain.nl...] --> [domain.nl...]
[domain.nl...] --> [domain.nl...]
[domain.nl...] --> /do.php?page=1
[domain.nl...] --> [domain.nl...]
[domain.nl...] --> [domain.nl...]
[domain.nl...] --> /domap.php?map1=word
[domain.nl...] --> [domain.nl...]
[domain.nl...] --> [domain.nl...]
[domain.nl...] --> domap.php?map1=word&map2=two
[sub.domain.nl...] --> [sub.domain.nl...]
[sub.domain.nl...] --> [sub.domain.nl...]
[sub.domain.nl...] --> /sd_sub/domap.php?map1=word
[sub.domain.nl...] --> [sub.domain.nl...]
[sub.domain.nl...] --> /sd_sub/domap.php?map1=word&map2=two
[sub.domain.nl...] --> [sub.domain.nl...]
[sub.domain.nl...] --> [sub.domain.nl...]
[sub.domain.nl...] --> /sd_sub/do.php?page=1
Of course the "word" is a [a-z] and "two" is a [a-z], the number 1 is [0-9], and "sub" is [a-z0-9].
In short:
1) there must always be a slash if it's not a file itself (302)
2) first maps /[0-9]/ must point to a do.php file on every subdomain
3) first maps /[a-z]/ must point to a domap.php file on every subdomain
4) second maps /[a-z]/[a-z]/ must point to a domap.php file on every subdomain
5) if there is no subdomain precent (the directory doesnt exist, server must respond with a 404 error code.
RewriteEngine on
RewriteBase /
Options -MultiViews
# If no-www domain requested, externally redirect to www domain
RewriteCond %{HTTP_HOST} ^domain\.be
RewriteRule (.*) [domain.be...] [R=301,L]
# If www+subdomain domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.domain\.be
RewriteRule (.*) [%1.domain.be...] [R=301,L]
# If subdomain+www domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.domain\.be
RewriteRule (.*) [%1.domain.be...] [R=301,L]
# 0..9 (WWW add slash)
RewriteCond %{HTTP_HOST} ^www\.domain\.be
RewriteRule ^([0-9]+)$ [domain.be...] [R=302]
# 0..9 (WWW rewrite)
RewriteCond %{HTTP_HOST} ^www\.domain\.be
RewriteRule ^([0-9]+)/$ /do.php?page=$1 [L]
# 0..9 (SUB add slash)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.be
RewriteRule ^([0-9]+)$ [%1.domain.be...] [R=302]
# 0..9 (SUB rewrite)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.be
RewriteRule ^([0-9]+)/$ /sd_%1/do.php?page=$1 [L]
# map1 (WWW add slash)
RewriteCond %{HTTP_HOST} ^www\.domain\.be
RewriteRule ^([a-z]+)$ [domain.be...] [R=302]
# map1 (WWW rewrite)
RewriteCond %{HTTP_HOST} ^www\.domain\.be
RewriteRule ^([a-z]+)/$ /domap.php?map1=$1 [L]
# map1 (SUB add slash)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.be
RewriteRule ^([a-z]+)$ [%1.domain.be...] [R=302]
# map1 (SUB rewrite)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.be
RewriteRule ^([a-z]+)/$ /sd_%1/domap.php?map1=$1 [L]
# map2 (WWW add slash)
RewriteCond %{HTTP_HOST} ^www\.domain\.be
RewriteRule ^([a-z]+)/([a-z]+)$ [domain.be...] [R=302]
# map2 (WWW rewrite)
RewriteCond %{HTTP_HOST} ^www\.domain\.be
RewriteRule ^([a-z]+)/([a-z]+)/$ /domap.php?map1=$1&map2=$2 [L]
# map2 (SUB add slash)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.be
RewriteRule ^([a-z]+)/([a-z]+)$ [%1.domain.be...] [R=302]
# map2 (SUB rewrite)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.be
RewriteRule ^([a-z]+)/([a-z]+)/$ /sd_%1/domap.php?map1=$1&map2=$2 [L]
RewriteEngine on
RewriteBase /
Options -MultiViews
# If no-wwwdomain requested, externally redirect to www domain
RewriteCond %{HTTP_HOST} ^domain\.nl
RewriteRule (.*) [domain.nl...] [R=301,L]
# If www+sub requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
# If subdomain+www domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
#### SOME PROBLEM HERE IF PEOPLE JUST REQUESTING [sub.domain.nl...]
# index (SUB add slash)
# RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
# RewriteRule ^$ [%1.domain.nl...] [R=301]
# index (SUB rewrite)
# RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
# RewriteRule ^$ /subdomains/%1/index.php?sub=%1&page=$1 [L]
# 0..9 (WWW add slash)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([0-9]+)$ [domain.nl...] [R=301]
# 0..9 (WWW rewrite)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([0-9]+)/$ /do.php?page=$1 [L]
# 0..9 (SUB add slash)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^([0-9]+)$ [%1.domain.nl...] [R=301]
# 0..9 (SUB rewrite)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^([0-9]+)/$ /subdomains/%1/do.php?sub=%1&page=$1 [L]
# map1 (WWW add slash)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([a-z]+)$ [domain.nl...] [R=301]
# map1 (WWW rewrite)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([a-z]+)/$ /domap.php?map1=$1 [L]
# map1 (SUB add slash)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^([a-z]+)$ [%1.domain.nl...] [R=301]
# map1 (SUB rewrite)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^([a-z]+)/$ /subdomains/%1/domap.php?sub=%1&map1=$1 [L]
# map2 (WWW add slash)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)$ [domain.nl...] [R=301]
# map2 (WWW rewrite)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)/$ /domap.php?map1=$1&map2=$2 [L]
# map2 (SUB add slash)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)$ [%1.domain.nl...] [R=301]
# map2 (SUB rewrite)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)/$ /subdomains/%1/domap.php?sub=%1&map1=$1&map2=$2 [L]
I have some problem still with the normal requests.
Is it correct to do it this way? Can it be simpeler?
I have this:
RewriteEngine on
RewriteBase /
Options -MultiViews
# If no-wwwdomain requested, externally redirect to www domain
RewriteCond %{HTTP_HOST} ^domain\.nl
RewriteRule (.*) [domain.nl...] [R=301,L]
# If www+sub requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
# If subdomain+www domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.domain\.nl
RewriteRule (.*) [%1.domain.nl...] [R=301,L]
# 0..9 (WWW add slash)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([0-9]+)$ [domain.nl...] [R=301]
# 0..9 (WWW rewrite)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([0-9]+)/$ /do.php?page=$1 [L]
# map1 (WWW add slash)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([a-z]+)$ [domain.nl...] [R=301]
# map1 (WWW rewrite)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([a-z]+)/$ /domap.php?map1=$1 [L]
# map2 (WWW add slash)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)$ [domain.nl...] [R=301]
# map2 (WWW rewrite)
RewriteCond %{HTTP_HOST} ^www\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)/$ /domap.php?map1=$1&map2=$2 [L]
# map2 (SUB add slash)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)$ [%1.domain.nl...] [R=301]
# map2 (SUB rewrite)
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^([a-z]+)/([a-z]+)/$ /subdomains/%1/domap.php?sub=%1&map1=$1&map2=$2 [L]
#### SOME PROBLEM HERE IF PEOPLE JUST REQUESTING [sub.domain.nl...]
# index (SUB add slash)
# RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
# RewriteRule ^$ [%1.domain.nl...] [R=301]
# index (SUB rewrite)
RewriteCond %{HTTP_HOST}!^www\.domain\.nl
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^$ /subdomains/%1/ [L]
#### SOME PROBLEM HERE IF PEOPLE JUST REQUESTING [sub.domain.nl...]# index (SUB add slash)
# RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
# RewriteRule ^$ http://%1.domain.nl/ [R=301]
If your intent is to redirect a request for "http://sub.domain.nl" with no trailing slash to "http://sub.domain.nl/" with a trailing slash, then you need to look at {REQUEST_URI} and make sure it has no trailing slash before redirecting:
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.nl
RewriteRule ^$ http://%1.domain.nl/ [R=301]
Jim
# if the HOST is not www.domain.nl skip the next 6 rules
RewriteCond %{HTTP_HOST} !^www\.domain\.nl
RewriteRule . - [S=6]
# add /
RewriteCond %{REQUEST_URI}!/$
RewriteRule ^$ http://%1.domain.nl/ [R=301]
# 0..9 (WWW rewrite)
RewriteRule ^([0-9]+)/$ /do.php?page=$1 [L]
# map1 (WWW add slash)
RewriteRule ^([a-z]+)$ http://www.domain.nl/$1/ [R=301]
# map1 (WWW rewrite)
RewriteRule ^([a-z]+)/$ /domap.php?map1=$1 [L]
# map2 (WWW add slash)
RewriteRule ^([a-z]+)/([a-z]+)$ http://www.domain.nl/$1/$2/ [R=301]
# map2 (WWW rewrite)
RewriteRule ^([a-z]+)/([a-z]+)/$ /domap.php?map1=$1&map2=$2 [L]
Justin