Portál AbcLinuxu, 13. května 2025 21:43

Dotaz: htaccess dynamické subdomény

14.1.2009 08:47 HosipLan | skóre: 2
htaccess dynamické subdomény
Přečteno: 1056×
Odpovědět | Admin

Zdravím,
za včerejšek jsem prošel dobrých 30 metod jak si pořešit subdomény, potřebuju takhle podstrčit:
blog.kdyby.org -> kdyby.org/blog.php
download.kdyby.org -> kdyby.org/download.php
libs.kdyby.org -> kdyby.org/libs.php

a potom chci mít dynamické subdomény ve složce /subdomains takze treba
test1.kdyby.org -> kdyby.org/subdomains/test1
test2.kdyby.org -> kdyby.org/subdomains/test2
test3.kdyby.org -> kdyby.org/subdomains/test3

Poskládal jsem rewrite který by měl fungovat podle asi 20ceti návodů
ovšem řve na mě krásná 500


RewriteEngine On

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

RewriteCond %{HTTP_HOST} ^([a-z][a-z0-9]+)\.kdyby\.org$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{1} ^(blog|download|libs|documentation|helper)$ [NC]
Rewriterule ^(.*)$ %{DOCUMENT_ROOT}/%{1}.php [L]

RewriteCond %{HTTP_HOST} ^([a-z][a-z0-9]+)\.kdyby\.org$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{1} !^(blog|download|libs|documentation|helper)$ [NC]
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/subdomains/%{1}/index.php [L]
Nástroje: Začni sledovat (0) ?Zašle upozornění na váš email při vložení nového komentáře.

Odpovědi

14.1.2009 11:36 HosipLan | skóre: 2
Rozbalit Rozbalit vše Re: htaccess dynamické subdomény
Odpovědět | | Sbalit | Link | Blokovat | Admin

Kamarád mi dal k dispozici svůj rewrite který ma použitý a funguje


RewriteCond %{HTTP_HOST} ^[^.]+\.aeternum.cz$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.aeternum.cz(.*) /var/www/web.aeternum.cz$2

Tak jsem si ho upravil, ovšem blog.kdyby.org mi hází 500 a barak.kdyby.org mi hází Forbidden


RewriteCond %{HTTP_HOST} ^([^.]+)\.kdyby\.org$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(blog|download|libs|documentation|helper)\.kdyby\.org$ [NC]
RewriteRule ^(.+)$ %{HTTP_HOST}$1 [C]
RewriteRule ^([^\.]+)\.kdyby\.org(.*) %{DOCUMENT_ROOT}/$2.php [L]

RewriteCond %{HTTP_HOST} ^([^.]+)\.kdyby\.org$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^(blog|download|libs|documentation|helper)\.kdyby\.org$ [NC]
RewriteRule ^(.+)$ %{HTTP_HOST}$1 [C]
RewriteRule ^([^\.]+)\.kdyby\.org(.*)$ %{DOCUMENT_ROOT}/subdomains/$2/index.php [L]

Ten forbidden vypadá takhle (docela úlet):


Forbidden

You don't have permission to access /subdomains/subdomains/subdomains/subdomains/subdomains/subdomains/subdomains/subdomains/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/subdomains/subdomains/............... ............../index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/subdomains/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/subdomains/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php on this server.
14.1.2009 12:23 HosipLan | skóre: 2
Rozbalit Rozbalit vše Re: htaccess dynamické subdomény
Takže přecejenom nakonec to vyřešil google :-)

RewriteCond %{ENV:REDIRECT_STATUS} ^$ jako první pravidlo pro oba rewrity a jsem za vodou

Omlouvám se za zbytečné vlákno :) ikdyž snad to někomu pomůže

Založit nové vláknoNahoru

Tiskni Sdílej: Linkuj Jaggni to Vybrali.sme.sk Google Del.icio.us Facebook

ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.