Forum Moderators: phranque

Message Too Old, No Replies

Apache Rewrite Help

In .htaccess

         

graff41

7:32 pm on Feb 22, 2010 (gmt 0)

10+ Year Member



Based on this code for allowing non-existing folder paths to resolve to the web root:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


..and without knowing more about apache I have come up with this...


RewriteCond %{REQUEST_URI}!^/
RewriteRule . /index.php [L]


But, it doesn't work, of course.

I want ALL subdomains xyz.domain.com, 123.domain.com and even abc.xyz.123.890.domain.com to resolve to the same webroot. I do not need folder mapping. And I would prefer that the provided URL stay in the location bar of the browser, so not a redirect.

It is a linux box, with plesk on it running php if that makes a difference.

Currently when I go to a subdomain, it takes me to the default plesk page.

Thanks for any help in advance.

jdMorgan

3:11 am on Feb 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a Plesk issue, not a mod_rewrite issue.

Unless you have a unique IP address for your server, you need to "map" your subdomains to some folder (even if it's the same one) using Plesk. Having done that, your mod_rewrite code (in .htaccess I presume) will then have some effect.

This also requires the subdomains (or a wild-card) to be defined in your DNS Zone file.

Jim

graff41

10:52 pm on Feb 24, 2010 (gmt 0)

10+ Year Member



Thanks for your response.

I can't create a new subdomain in plesk for every subdomain. I have been on a plesk box before and not needed to create the subdomains.

I am hosting DNS elsewhere and I do have a wildcard(*) entry there for all subdomains to point to the ip.

I am sure apache will iron this out. Does anyone else run a similar setup?

Thanks.

jdMorgan

4:30 am on Feb 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you have a dedicated (not-shared) IP address for this server? If so, then it's an IP-based virtual server, and not a name-based virtual server, and the control panel should have settings to point all requests for all domains and subdomains to whatever filespace(s) you want.

If it's a shared IP address, then you will have to define all domains individually in the control panel, although you may be able to 'wild-card' their subbdomains in this configuration as well.

Jim

graff41

5:04 pm on Feb 25, 2010 (gmt 0)

10+ Year Member



Thanks for your continued help.

It is a dedicated box with 4 ips 2 shared 2 exclusive. This domain is the only one on an exclusive IP.

I think the main problem here is PLESK, they don't allow wild-card subdomain configuration, unless someone out there knows a way to do it.