Autor Zpráva
Martin vv
Profil *
Ahoj, mám v htaccess tento kod, který mi způsobuje nefunkčnost podstránek na subdoménách, když jej odstraním, tak zase nefungují podstránky na hlavní doméně. Jak jej vhodně přepsat? Děkuji Vám

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|\.woff|\.woff2|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Kajman
Profil
Žádná jiná pravidla, se kterými by funkčnost mohla kolidovat, tam nejsou?
Martin vv
Profil *
ano, celkově je tam toto:


RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|\.woff|\.woff2|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(assets)/(.*)$ public/$1/$2 [L,NC]

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

# disable viewing all hiden files
RedirectMatch 403 /\..*$

# cache
<FilesMatch "\.(?i:gif|jpe?g|png|ico|css|js|swf)$">
  <IfModule mod_headers.c>
    Header set Cache-Control "max-age=172800, public, must-revalidate"
  </IfModule>
</FilesMatch>

# disable browsing other files in root
RedirectMatch 403 /composer.*
RedirectMatch 403 /artisan
RedirectMatch 403 /phpunit.xml

# disable browsing directories
# this should be solved also with Option -Indexes, however...
RedirectMatch 403 ^/app
RedirectMatch 403 ^/artisan
RedirectMatch 403 ^/bootstrap
RedirectMatch 403 ^/config
RedirectMatch 403 ^/database
RedirectMatch 403 ^/modules
RedirectMatch 403 ^/scripts
RedirectMatch 403 ^/storage
RedirectMatch 403 ^/tests
RedirectMatch 403 ^/vendor


# htaccess rules for subdomains and aliases
# to create new subdomain, create a folder www/subdom/(subdomain name)
# to create web for alias, create a folder www/domains/(whole domain name)

# htaccess pravidla pro subdomeny a samostatne weby aliasu
# pro vytvoreni subdomeny vytvorte adresar www/subdom/(nazev subdomeny)
# pro vytvoreni webu pro alias vytvorte adresar www/domains/(cely domenovy nazev)
# dalsi info a priklady: http://kb.wedos.com/r/32/webhosting-htaccess.html



# cele domeny (aliasy)
RewriteCond %{REQUEST_URI} !^domains/
RewriteCond %{REQUEST_URI} !^/domains/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$
RewriteCond %{DOCUMENT_ROOT}/domains/%2 -d
RewriteRule (.*) domains/%2/$1 [DPI]

# subdomeny (s nebo bez www na zacatku)
RewriteCond %{REQUEST_URI} !^subdom/
RewriteCond %{REQUEST_URI} !^/subdom/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\.([^\.]*)\.([^\.]*)$
RewriteCond %{DOCUMENT_ROOT}/subdom/%2 -d
RewriteRule (.*) subdom/%2/$1 [DPI]

# aliasy - spravne presmerovani pri chybejicim /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^domains/[^/]+/(.+[^/])$ /$1/ [R]

# subdomeny - spravne presmerovani pri chybejicim /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^subdom/[^/]+/(.+[^/])$ /$1/ [R]



Martin vv:
ano celkově je tam toto:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|\.woff|\.woff2|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(assets)/(.*)$ public/$1/$2 [L,NC]

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

# disable viewing all hiden files
RedirectMatch 403 /\..*$

# cache
<FilesMatch "\.(?i:gif|jpe?g|png|ico|css|js|swf)$">
  <IfModule mod_headers.c>
    Header set Cache-Control "max-age=172800, public, must-revalidate"
  </IfModule>
</FilesMatch>

# disable browsing other files in root
RedirectMatch 403 /composer.*
RedirectMatch 403 /artisan
RedirectMatch 403 /phpunit.xml

# disable browsing directories
# this should be solved also with Option -Indexes, however...
RedirectMatch 403 ^/app
RedirectMatch 403 ^/artisan
RedirectMatch 403 ^/bootstrap
RedirectMatch 403 ^/config
RedirectMatch 403 ^/database
RedirectMatch 403 ^/modules
RedirectMatch 403 ^/scripts
RedirectMatch 403 ^/storage
RedirectMatch 403 ^/tests
RedirectMatch 403 ^/vendor


# htaccess rules for subdomains and aliases
# to create new subdomain, create a folder www/subdom/(subdomain name)
# to create web for alias, create a folder www/domains/(whole domain name)

# htaccess pravidla pro subdomeny a samostatne weby aliasu
# pro vytvoreni subdomeny vytvorte adresar www/subdom/(nazev subdomeny)
# pro vytvoreni webu pro alias vytvorte adresar www/domains/(cely domenovy nazev)
# dalsi info a priklady: http://kb.wedos.com/r/32/webhosting-htaccess.html



# cele domeny (aliasy)
RewriteCond %{REQUEST_URI} !^domains/
RewriteCond %{REQUEST_URI} !^/domains/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$
RewriteCond %{DOCUMENT_ROOT}/domains/%2 -d
RewriteRule (.*) domains/%2/$1 [DPI]

# subdomeny (s nebo bez www na zacatku)
RewriteCond %{REQUEST_URI} !^subdom/
RewriteCond %{REQUEST_URI} !^/subdom/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\.([^\.]*)\.([^\.]*)$
RewriteCond %{DOCUMENT_ROOT}/subdom/%2 -d
RewriteRule (.*) subdom/%2/$1 [DPI]

# aliasy - spravne presmerovani pri chybejicim /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^domains/[^/]+/(.+[^/])$ /$1/ [R]

# subdomeny - spravne presmerovani pri chybejicim /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^subdom/[^/]+/(.+[^/])$ /$1/ [R]



Kajman,
Kajman
Profil
Zkuste dát kód z [#1] až na konec.

Pokud budou subdomény zlobit i nadále, zkuste i do nich dát .htaccess a zakázat tam podstrkávání
RewriteEngine Off

Navíc bych asi u všech RewriteRule použil flag L a tam kde je flag R, bych přidal i flag NE.

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: