Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-04-2012, 10:18 AM   PM User | #1
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,526
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Can I use rewrite to create virtual sub-domains ?

Hi,

Can I use mod rewrite to create virtual sub-domains ?

What I mean is, if someone comes to my site
with fish.example.com

can mod_rewrite redirect them to:
example.com/store/search.php?prod=fish

There are no real sub-domains on my example.com

Thanks


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 01-04-2012, 10:20 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
There are some threads even in this forum, related to your question. Have a look at http://www.google.com/search?q=site%...rite+subdomain
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 01-04-2012, 04:24 PM   PM User | #3
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,526
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
OK - thanks for the advice.

I have gone away and done some stuff that should work.

My .htaccess reads:
PHP Code:
Options +FollowSymLinks 
RewriteEngine On

# BELOW IS STUFF TO BLOCK SPAMMING ATTACKS 
######################################################
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRINGmosConfig_[a-zA-Z_]{1,21}(=|%3D) [OR]

# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRINGbase64_encode.*(.*) [OR]

# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]

# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRINGGLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]

# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING_REQUEST(=|[|%[0-9A-Z]{0,2})

# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [NC,L]
#
######################################################

RewriteCond %{HTTP_HOST} ^([^.]+).my-gigs.net [NC]
RewriteCond %{HTTP_HOST} !^www.my-gigs.net [NC]
RewriteRule ^.*$ /index.php?cdz=%[QSA,L
Then on my "index.php" page :

PHP Code:
if(isset($_GET["cdz"])){   
    
$the_key $_GET["cdz"];
    
$the_key=$the_key."php";
    
header("Location: /$the_key");
    exit();
    }  
// end if 
I also added a "A" Record to my DNS records:
* A - IPv4 Address 65.xx.xxx.xxx

BUT, when I enter : mobilewebsite.my-gigs.net
into my browser I get this:

The browser goes to this:

reviewsworthreading.com/wp-signup.php?new=mobilewebsite.my-gigs.net

Now reviewsworthreading.com is a multiuser network worpdpress site which also has in its domain a wildcard A Record.

Both domains are on the same sever and on the same IP address.

I suppose it not surprising that things are getting a bit muddled ?

But is there a solution ?
I could ask my server supplier for a new IP address.

Any thoughts ?


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Old 01-05-2012, 08:22 AM   PM User | #4
leslie.jones
New Coder

 
Join Date: Nov 2011
Posts: 88
Thanks: 4
Thanked 26 Times in 26 Posts
leslie.jones is an unknown quantity at this point
My thoughts would be:

1: a specific DNS entry for the subdomain to get it to the right server. It looks like that is all in order:

Code:
dig +short mobilewebsite.xxxxxxx.net
xx.xx.xx9.163
dig +short xxxxxxx.net
xx.xx.xx9.163
2: The ALIAS directive on your APACHE virtual host will need to catch your virtual subdomains 'mobilewebsite' [and any others you are using], otherwise requests will drop through to the default site.
An UNTESTED example vh config:
Code:
<VirtualHost *:80>
DocumentRoot /var/www/sitename/htdocs
ServerName  sitename.com
ServerAlias mobilesite.sitename.com subdomain2.sitename.com subdomain3.sitename.com
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/sitename/htdocs>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ScriptAlias /cgi-bin/ /var/www/sitename/htdocs/cgi-bin/
        <Directory "/var/www/sitename/htdocs/cgi-bin">
                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog /var/log/apache/error.log
        CustomLog /var/log/apache/access.log combined
</VirtualHost>
I don't know what your server hosting set up is, or if you can edit the Apache configs directly. If you can't you can probably find some control panel option for adding subdomains which, with a little creativity, can be used or tricked into doing what you want.
leslie.jones is offline   Reply With Quote
Old 01-05-2012, 09:47 AM   PM User | #5
jeddi
Senior Coder

 
Join Date: May 2006
Posts: 1,526
Thanks: 26
Thanked 4 Times in 4 Posts
jeddi has a little shameless behaviour in the past
Thanks for those insights.

I will look into the use of alias' that could be the answer


.
__________________
If you want to attract and keep more clients, then offer great customer support.

Support-Focus.com. automates the process and gives you a trust seal to place on your website.
I recommend that you at least take the 30 day free trial.
jeddi is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:47 AM.


Advertisement
Log in to turn off these ads.