subdomain.site.tld/index.php/subdomain/smth/param1/paramN

Using a single web hosting account to host multiple sites

subdomain.site.tld/index.php/subdomain/smth/param1/paramN

Postby cagliostro » Mon Jan 22, 2007 2:53 am

Hello everybody

I need some help to accomplish .htaccess URI rewriting...

I tried to write some of .htaccess code myself but could do that only for the limited version of URI, like: http://whateversubdomain.site.com/ transforms into http://whateversubdomain.site.com/index ... rsubdomain

Code: Select all
RewriteEngine On

# Rewrite www.domain.com to domain.com
RewriteCond %{HTTP_HOST} ^www.(.*)
RewriteRule ^(.*)       http://%1/$1 [R=302,L]

# Rewrite subdomain.domain.com to
# subdomain.domain.com/index.php/subdomain
# but do not show /index.php/subdomain
RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.(ru|com|nl|eu)$
RewriteRule ^$ %{HTTP_HOST} [C]
RewriteRule ^((.*)\.(.*)\.(ru|com|nl|eu)) http://$1/index.php/$2 [QSA,L]

But the task is:

If user types in something like that:
http://whateversubdomain.site.com/somet ... parameterN
I'd like the URL to remain the same but server to execute something like that:
http://whateversubdomain.site.com/index ... parameterN

So, basically my problem is how to pass /something2/parameter1/parameter2/parameterN from the original URI into rewritten one...?

Btw, wilcard DNS is turned on.

Thank you very much in advance,
Mikhail
cagliostro
 
Posts: 3
Joined: Mon Jan 22, 2007 2:07 am
Location: The Netherlands

Postby richardk » Mon Jan 22, 2007 10:16 am

This should do it:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# don't rewrite sub requests
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(.+)\.[^\.]+\.(ru|com|nl|eu)$ [NC]
RewriteRule ^(.*)$ /index.php/%1/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby cagliostro » Mon Jan 22, 2007 1:58 pm

richardk wrote:This should do it:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# don't rewrite sub requests
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(.+)\.[^\.]+\.(ru|com|nl|eu)$ [NC]
RewriteRule ^(.*)$ /index.php/%1/$1 [QSA,L]


Richard, it is awesome! Thank you very much indeed for your help!
cagliostro
 
Posts: 3
Joined: Mon Jan 22, 2007 2:07 am
Location: The Netherlands

Postby cagliostro » Thu Jan 25, 2007 1:58 am

Richard, hello

Could please help me again?

Your solution works fine for the site domain but looks like these .htaccess settings do not apply to parked domains.

Example: http://news.izba.nl/welcome/test/1/2 works fine.
I have parked benelux.in domain on top of izba.nl but the the altered request:
http://news.benelux.in/welcome/test/1/2 fails with 404

Any ideas how to apply these settings to parked domais as well?

Thank you very much in advance!

Mikhail
cagliostro
 
Posts: 3
Joined: Mon Jan 22, 2007 2:07 am
Location: The Netherlands

Postby richardk » Fri Jan 26, 2007 9:50 am

It should work. What happens if you replace [QSA,L] with [R,L]? Do you get redirected to the wrong place or not at all?

You could also try this:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^(.+)\.[^\.]+\.(ru|com|nl|eu)$ [NC]
RewriteRule !^index\.php(/.*)?$ /index.php/%1%{REQUEST_URI} [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 28 guests

cron