Jump to content

Recommended Posts

Can I make a file, so that when my page reads a URL like:

 

somedomain.hostbox.us

it reads it into a file like this:

hostbox.us/readFile.php?url=somedomain

 

 

another way:

somedomain.hostbox.us/somedir/mypage.php

and it reads it into a file like this:

hostbox.us/readFile.php?url=somedomain&page=somedir/mypage.php

Link to comment
https://forums.phpfreaks.com/topic/82628-solved-subdomain-urls/
Share on other sites

Setting up some sort of custom subdomain situation seems to be your focus right now. Honestly, these types of things are handled by Apache, and you really should take this to the appropriate board if you want the best help with it...

 

PhREEEk

 

I don't have access to apache, only Htaccess, and custom php ini files.

Link to comment
https://forums.phpfreaks.com/topic/82628-solved-subdomain-urls/#findComment-420240
Share on other sites

If you have a hosting package, your package either comes with x number of subdomains or not. If not, and you create them anyways, you would likely be violating your TOS with your hosting company. If you have access to .htaccess, .htaccess IS a document used by Apache, so it is an Apache issue...

 

PhREEEk

Link to comment
https://forums.phpfreaks.com/topic/82628-solved-subdomain-urls/#findComment-420242
Share on other sites

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.hostbox\.us
RewriteRule ^/(.*)$  viewFile.php?user=$1 [L]

 

I tried that, and all I get is a "Server not found" error on this: http://test.hostbox.us/

 

viewFile.php does exist, and it contains this text:

<?php
echo $_GET['user'];
?>

 

Any Ideas?

Link to comment
https://forums.phpfreaks.com/topic/82628-solved-subdomain-urls/#findComment-420499
Share on other sites

OK, here is what I have now!

RewriteEngine On

Options -MultiViews

#RewriteCond %{REQUEST_URI}!^/sd_
#RewriteCond %{HTTP_HOST}!^www\.hostbox\.us [NC]
#RewriteCond %{HTTP_HOST} ^([^.]+)\.hostbox\.us
#RewriteRule (.*) /sd_%1/$1 [L] 
RewriteCond %{HTTP_HOST} !^www\.hostbox\.us
RewriteCond %{HTTP_HOST} ([^.]+)\.hostbox\.us [NC]
Options +FollowSymlinks
RewriteRule ^http://(.*)\.hostbox\.us$ http://hostbox.us/viewFile.php?user=$1 [L,R]

 

basically it works, the problem is that it only shows the root folder tree of my hostbox.us folder. It isn't loading viewFile.php in the background anyone know why?

Link to comment
https://forums.phpfreaks.com/topic/82628-solved-subdomain-urls/#findComment-420650
Share on other sites

Looks like I got it!!

 

Options +FollowSymLinks

RewriteEngine On

# Fix missing trailing slashes.
RewriteCond %{HTTP_HOST} !^(www\.)?hostbox\.us$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.hostbox\.us$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%2%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# Rewrite sub domains.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?hostbox\.us$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.hostbox\.us$ [NC]
RewriteRule ^(.*)$ subdomains/%2/$1 [QSA,L]

Link to comment
https://forums.phpfreaks.com/topic/82628-solved-subdomain-urls/#findComment-422161
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.