Absurde rewrite

Using a single web hosting account to host multiple sites

Absurde rewrite

Postby Kian » Mon Sep 07, 2009 9:09 am

Hi all

I've Plesk with 10 subdomain included with DNS

1) I've the following structure:

domain.tld/index.php?site=forum

I want to rewrite it in

forum.domain.tld

I'm trying with no success this htaccess

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} forum.domain.tld
RewriteCond %{REQUEST_URI} !index.php?site=forum
RewriteRule ^(.*)$ forum.domain.tld/$1 [L]


2) Same question but a bit different. I've the following link

domain.tld/index.php?site=article

I want to rewrite article --in--> blog then

blog.domain.tld

3) Let's SEO :) just need a little help to start

domain.tld/index.php?site=forum&board=2

I want to rewrite forum.domain.tld (already rewrited in the first point) in this way

forum.domain.tld/Board-Name.html

I short first i've to set "-" instead of "_" or "*space*" with this rule

#RewriteRule !\.(html)$ - [S=4]
#RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=uscor:Yes]
#RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=uscor:Yes]
#RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=uscor:Yes]
#RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=uscor:Yes]


Then i've to query the database

SELECT boardname WHERE boardID=2

I'm trying really hard with no success :(


I want to underline that it's 5 days that i'm reding tons of pages documentation and that i'm trying hundreds of rewrite rules but i really need an help to start. I asked for help in several forums but nobody really helped me :(
Kian
 
Posts: 11
Joined: Mon Sep 07, 2009 5:45 am

Postby richardk » Mon Sep 07, 2009 10:35 am

What happens when you visit forum.example.com and blog.example.com? (Without any mod_rewrite.)

3) Let's SEO just need a little help to start

domain.tld/index.php?site=forum&board=2

I want to rewrite forum.domain.tld (already rewrited in the first point) in this way

forum.domain.tld/Board-Name.html

See FAQ: How to change a numeric ID into a name/title.

Something like
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# forum.example.com --> /index.php?site=forum
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^forum\.example\.com$ [NC]
RewriteRule ^$ /index.php?site=forum [QSA,L]

# forum.example.com/Board-Name.html --> /index.php?site=forum&BOARD_NAME=Board-Name
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^forum\.example\.com$ [NC]
RewriteRule ^([^/]+)\.html$ /index.php?site=forum&BOARD_NAME=$1 [QSA,L]

# blog.example.com --> /index.php?site=article
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^blog\.example\.com$ [NC]
RewriteRule ^$ /index.php?site=article [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Kian » Mon Sep 07, 2009 2:51 pm

First of all thank you very much for your reply... finally i can see some rewrite function in action.

When i visit forum.example.com (or other subdomains) i see Plesk default page (index.html). I tryed your code but nothing happens.

I want to specify that i've the following folders structure

Main folder
/httpdocs

Subdomain folders
/subdomains/forum/httpdocs
/subdomains/blog/httpdocs

I tryed your code in both httpdocs folder (main and subdomain)

/httpdocs/.htaccess
/subdomains/forum/httpdocs/.htaccess

When i visit example.com or forum.example.com nothing happens. Of course i fixed your code replacing forum\.mywebsite\.com to forum\.example\.com
Kian
 
Posts: 11
Joined: Mon Sep 07, 2009 5:45 am

Postby richardk » Tue Sep 08, 2009 7:45 am

Subdomain folders
/subdomains/forum/httpdocs
/subdomains/blog/httpdocs

Can you change them?

If you can't change them, create an index.php file in each with the following in them (/subdomains/forum/httpdocs/index.php and /subdomains/blog/httpdocs/index.php)
Code: Select all
<?php include('../../../httpdocs/index.php');


Then in /subdomains/forum/httpdocs/.htaccess
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# forum.example.com --> /index.php?site=forum
RewriteRule ^$ /index.php?site=forum [QSA,L]

# forum.example.com/Board-Name.html --> /index.php?site=forum&BOARD_NAME=Board-Name
RewriteRule ^([^/]+)\.html$ /index.php?site=forum&BOARD_NAME=$1 [QSA,L]


And in /subdomains/blog/httpdocs/.htaccess
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# blog.example.com --> /index.php?site=article
RewriteRule ^$ /index.php?site=article [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Kian » Tue Sep 08, 2009 10:51 am

Thank you again

The method you posted is cool :D but...
Warning: include() [function.include]: open_basedir restriction in effect. File() is not within the allowed path(s)

I can't include index.php from subdomain to main domain. I can only go up this folder ../httpdocs/index.php. The following ones are impossible (Operation not permitted)
../httpdocs/index.php
../../httpdocs/index.php
../../../httpdocs/index.php
and so on

I'm 99.99% sure that there is no way to skip this issue so we've to change the approach... it's really hard and i'm newbie :x

p.s. I really appreciate your help
Kian
 
Posts: 11
Joined: Mon Sep 07, 2009 5:45 am

Postby richardk » Tue Sep 08, 2009 4:22 pm

And you can't change the sub domain's document root (/subdomains/forum/httpdocs)? Then the only mod_rewrite solution would be to proxy the request (but this will be inefficient).

In /subdomains/forum/httpdocs/.htaccess
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# forum.example.com --> /index.php?site=forum
RewriteRule ^$ http://example.com/index.php?site=forum [P,L]

# forum.example.com/Board-Name.html --> /index.php?site=forum&BOARD_NAME=Board-Name
RewriteRule ^([^/]+)\.html$ http://example.com/index.php?site=forum&BOARD_NAME=$1 [P,L]


And in /subdomains/blog/httpdocs/.htaccess
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# blog.example.com --> /index.php?site=article
RewriteRule ^$ http://example.com/index.php?site=article [P,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Kian » Tue Sep 08, 2009 4:30 pm

richardk wrote:And you can't change the sub domain's document root (/subdomains/forum/httpdocs)?

Wait, i don't understand. What you mean? What do you want to change? Folder name? Structure? My hosting plan supports subdomains with redirect / rewrite rules then i'm totally sure that i can do what i need :wink:
Kian
 
Posts: 11
Joined: Mon Sep 07, 2009 5:45 am

Postby richardk » Tue Sep 08, 2009 4:48 pm

Change the folder eg. /subdomains/forum/httpdocs to /httpdocs. Not with mod_rewrite (you can't do that with mod_rewrite), with your hosting control panel or the Apache configuration.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Kian » Tue Sep 08, 2009 5:08 pm

This is the main domain with all website inside

domain.tld/httpdocs/admin
domain.tld/httpdocs/css
domain.tld/httpdocs/downloads
domain.tld/httpdocs/index.php
domain.tld/httpdocs/forum.php
domain.tld/httpdocs/articles.php

When i visit forum i just open index.php + forum.php (index.php?site=forum)

--------------------

This is the subdomain

domain.tld/subdomains/fourm/httpdocs/anyfolder
domain.tld/subdomains/fourm/httpdocs/anyfile
domain.tld/subdomains/forum/httpdocs/.htaccess
domain.tld/subdomains/blog/httpdocs/anyfolder
domain.tld/subdomains/blog/httpdocs/anyfile
domain.tld/subdomains/blog/httpdocs/.htaccess

This structure is good if i've separate website systems. For example i can install phpBB forum in subdomains/forum and Wordpress in subdomains/blog but the fact is that i don't have separate homepage - forum - blog. I've all contents included in the website (index.php?site=forum/article/whatever). Then how can i "spearate the inseparable"?

I was thinking to copy the entire website in all the subdomains folder to make it working but it's really sucks :S or not?

p.s. Tank you again
Kian
 
Posts: 11
Joined: Mon Sep 07, 2009 5:45 am

Postby richardk » Wed Sep 09, 2009 12:08 pm

I was thinking to copy the entire website in all the subdomains folder to make it working but it's really sucks :S or not?

If proxying didn't work (did you try it?) that might be your only solution.

You should ask your host if they can help you.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Next

Return to Domain Handling

Who is online

Users browsing this forum: Majestic-12 [Bot] and 17 guests

cron