I have several sub domains where it may be easy to mistype. I therefore setup a wildcard DNS so my site catches everything with my domain. The problem is I want to alert people they made a mistake. Currently the wildcard sends you to my homepage but I would like to make an “error” page letting people know they should check their typing.
Yep, but it will need to be in server side code. You would check for the value of HTTP_HOST then action accordingly
__________________
Chris. ->> Please login or register to view this content. Registration is FREE <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
The top code works great by itself but the bottom code causes a 500 internal server error. I was also told that the code below may work but as a novice I have no idea what it means.
# 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\.com(: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]
Oops, as a newbie I don’t think any of my code is server side? Can you guys point me in the right direction or does anyone have server side code that does this?