subdomain multiple file redirection?

Using a single web hosting account to host multiple sites

subdomain multiple file redirection?

Postby feketegy » Sat Sep 30, 2006 11:32 am

Okay, could somebody help me with this:

i managed to load different files based on subdomains:

ex. http://join.mysite.com -> loads join.php
http://main.mysite.com -> loads main.php

now the problem is that i want this:
http://join.mysite.com/activate/user_activation_code

to redirect to join.php (by the subdomain) and then redirects to activate.php in this file i want to use user-activation.code

how can this possible?
feketegy
 
Posts: 9
Joined: Wed Sep 13, 2006 9:06 am

Postby feketegy » Sat Sep 30, 2006 12:06 pm

i just saw that modrewrite.com is built up like my problem. so it is possible but how?
feketegy
 
Posts: 9
Joined: Wed Sep 13, 2006 9:06 am

Postby richardk » Sat Sep 30, 2006 2:19 pm

As far as i know modrewrite.com uses a standard subdomain.

to redirect to join.php (by the subdomain) and then redirects to activate.php in this file i want to use user-activation.code

You want it to do what? You want it to go to 2 files? You can't do that, you could include the second file from the first. Or are you asking for something else?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby feketegy » Sun Oct 01, 2006 1:08 am

no, you see how the url is built up on this site (modrewrite.com)...

there is: www.modrewrite.com which takes you to a page...
forum.modrewrite.com which takes you to the forum main page
forum.modrewrite.com/posting.php?mode=... which takes you to posting or viewtopic or someting else.

i want to do like this bu i want that the url to be clean url. so instead of
forum.modrewrite.com/posting.php/mode=something
i want
forum.modrewrite.com/posting/mode/

i don't know how to expain this...i hope you understand what i mean
feketegy
 
Posts: 9
Joined: Wed Sep 13, 2006 9:06 am

Postby richardk » Sun Oct 01, 2006 8:27 am

As far as i know, there's no mod_rewrite involved on this server. (There arn't clean URLs for this forum.)

now the problem is that i want this:
http://join.mysite.com/activate/user_activation_code

I don't understand what you want. What is the URL in the browser? What is the real URL/path? What is your current mod_rewrite code?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby feketegy » Sun Oct 01, 2006 9:10 am

Okay. I'll try to explain a little better.
So, I'm making a community site. I have different sections of the site.
like news, articles, forum, etc. All these sections can be accesed via subdomains.
In my apache server i setup a wildcard subdomain so everything (*.mysite.com) will forward to www.mysite.com and therefore the index.php is accessed. In the index.php file the script parses the $_SERVER['HTTP_HOST'] variable to find out which of the section to load.
for ex. if http://news.mysite.com is accessed then the index.php file parses the http_host and extracts the news part. So it will know that to load the news section. It simply loads news.php.

Okay, my problem is that if somebody tries to access http://news.mysite.com/category/politics than an error will occur because apache searches for politics or category. What i want is that with this url apache redirects it to news.php where i can parse the url more to give politics section in news.

All what i want from apache is to ignore everything after the / and only parses http://news.mysite.com even if the url is http://news.mysite.com/category/politics because the /category/politics i want to parse the news.php

If somebody writes for ex.: http://news.mysite.com/category/science
than the following proccess to occur:

apache (with the wildcard subdomain) forwards to www.mysite.com where the index.php is loaded in the index.php file the script would parse the http_host and extract the news therefore it will know which setion to load. It loads news.php and in this file extract the /category/science part and to load science news from a database...
feketegy
 
Posts: 9
Joined: Wed Sep 13, 2006 9:06 am

Postby richardk » Sun Oct 01, 2006 9:37 am

You could use this
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RweriteRule .* /index.php [QSA,L]

Include() the news.php file as normal and in it parse the $_SERVER['REQUEST_URI'] variable.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby feketegy » Sun Oct 01, 2006 9:58 am

okay, i'm not so much an expert in mod_rewrite. i know that i have to put the code above in .htaccess, but could you explain it to me a little bit more?

By the way i put the code in a .htaccess file in the root folder and it gives me an 500 Server Error
feketegy
 
Posts: 9
Joined: Wed Sep 13, 2006 9:06 am

Postby richardk » Sun Oct 01, 2006 10:27 am

By the way i put the code in a .htaccess file in the root folder and it gives me an 500 Server Error

Replace RweriteRule with RewriteRule.

could you explain it to me a little bit more?

Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-f

If the request is not for a real file.
Code: Select all
RewriteCond %{SCRIPT_FILENAME} !-d

And the request is not for a real directory.
Code: Select all
RewriteRule .* /index.php [QSA,L]

.* : match everything
/index.php : send the request to index.php
[L] : stop.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby feketegy » Sun Oct 01, 2006 11:04 am

yeah man this is working! thanks a lot. now could you tell if this method is efficient or should i optimize something?
feketegy
 
Posts: 9
Joined: Wed Sep 13, 2006 9:06 am

Next

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 45 guests

cron