문서 루트에 이런 식으로 뭔가를 시도 :
RewriteEngine On
# check if subdomain folder has the existing file, if so, serve it
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.co\.uk
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -f
RewriteRule ^(.*)$ /%1/$1 [L]
# check if subdomain folder has the existing directory WITH A TRAILING SLASH, if so serve it
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.co\.uk
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -d
RewriteRule ^(.*?)/$ /%1/$1/ [L]
# check if subdomain filder has the existing directory but missing trailing slash, redirect with it
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.co\.uk
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -d
RewriteRule ^(.*)$ /$1/ [R=301,L]
이 방법이 404이라면, 그것은 그래서 만약 내부적으로 재 작성하려고하지 않을 것이다, 당신을 위해이 일을하면 http://sub.domain.co.uk/this/path/does/not/exist/blah
으로 이동하면 /sub/this/path/does/not/exist/blah
이 존재하지 않는 404 메시지가 표시되지 않으며 URI가 다시 작성되지 않아 기본 디렉토리 구조가 노출되지 않기 때문에 /this/path/does/not/exist/blah
이라는 메시지 만 표시됩니다.
둘째로 DirectorySlash
이 켜져있을 가능성이 높습니다. 다시 말하면 슬래시가없는 http://sub.domain.co.uk/this/path
과 같은 디렉토리에 접근하면 mod_dir은 해당 슬래시를 리디렉션하고 추가하려고하지만 URI가 다시 작성되어 사용자에게 리디렉션되기 때문에 잘못되었을 가능성이 높습니다. http://sub.domain.co.uk/sub/this/path/
. sub
을 숨기는 올바른 URI와 함께 선행으로 슬래시를 추가합니다.
'-'는 무엇입니까? –
나는 그들이 사용하고있는 예에서 나왔는지 확신 할 수 없다. –