I am familiar with modifying .htaccess
files but my initial attempts to do so continue to fail.
Ultimately, I want to point users to 'imaginary' subdomains (those which do not exist) so that the subdomain can be parsed correctly with PHP and MySQL to find the particular member's information. It is my assumption that MediaTemple has something configured to always check for a true subdomain directory prior to any access so the .htaccess
file settings are never touched and in turn just generate errors.
For example:
When somebody goes to www.example.com
currently, it shows the parent site including information on how to become a member. Once a person is a member, their 'unique' URL is:
www.example.com?MemberID=12345
ultimately, forcing the member to remember the question mark agent equals can be confusing along with the need to remember the proper capitalization and such.
I would 'like' to achieve the following:
www.12345.example.com
redirects to
www.example.com/index.php?MemberID=12345
(index.php
reads the 12345
like a $_GET
function to properly lookup the ID
, valid and return response based on that.)
I believe we could? achieve the same using information after the slash:
e.g. www.example.com/12345
The issue is we already have other pages using /xxxx
to modify client content as well as I don't want to block anybody's ability to simply visit: www.example.com/contact
for example as a live link.
(where the site redirects to index, tries to look up memberid = 'contact' and does not find any results).
My .htaccess is currently:
ErrorDocument 404 /404.php
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(.+)\.example\.com
RewriteRule .* http://example.com/processing_page.php?ID=%1 [L,R]
I would expect based off my needs that typing www.something.example.com
I would be redirected to: www.example.com/processing_page.php?something
Instead, it just redirects to my mediatemple hosting page (essentially stating no subdomain named 'something' exists).
I am running our server on a Media Temple DV 3.5 server running CentOS5 and LAMP stack.
Sorry to hear about your issues. If you are still having issues, I'd recommend contacting our tech support and taking a look at our wiki on specific rules.
If you open up a support request, feel free to contact us through our Twitter or phone support.
This code wouldn't actually have done what you required. The first condition specifically excludes any hostname that starts
www.
, so it wouldn't have redirected a request forwww.something.example.com
. You would have had to have requestedsomething.example.com
for this directive to have stood a chance. Otherwise, you'd just get your default home page.This is assuming you have a "wildcard" subdomain configured in DNS and an appropriate
ServerAlias
directive defined in the virtual host for your site (and the webserver having been restarted).To modify the above directives to do what you require, you would have needed something like this instead:
This should also have gone before the first rule that appends the
.php
extension via an internal rewrite. Generally, redirects should always go before rewrites.