URL에 Ugly "Index.php/"가 없도록 Kohana의 .htaccess를 올바르게 설정하는 방법은 무엇입니까?

StackOverflow https://stackoverflow.com/questions/966429

  •  12-09-2019
  •  | 
  •  

문제

2 시간 후에 나는 그것을 올바르게 얻을 수 없었다.

Kohana 설치는 내 도메인 바로 아래에 액세스 할 수 있습니다.http://something.org/"

대신에 http://something.org/index.php/welcomde/index URL과 같은 URL을 원합니다 http://something.org/welcome/index

내 .htaccess가 완전히 엉망입니다. 실제로 다운로드와 함께 제공되는 표준 예제 htaccess입니다. 거의 쓸모가 없습니다. Kohana 페이지에는 "index.php를 제거하는 방법"자습서가 있습니다. 그것을 제거하는 방법에 대해서는 이야기하지 않기 때문에 정말 쓸모가 없습니다. 완전히 혼란 스럽습니다.

누군가가 표준 Kohana 설치에 대한 그의 .htaccess를 제공 할 수 있습니까?

도움이 되었습니까?

해결책

내 htaccess는 예처럼 보입니다.

RewriteEngine On

RewriteBase /

RewriteRule ^(application|modules|system) - [F,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]

그러나 당신은 또한 변경해야합니다 config.php 파일 :

$config['index_page'] = '';

다른 팁

이것은 지금 우리의 .htaccess 파일이며 작동하는 것 같습니다.

RewriteEngine On

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

웹 루트 외부의 응용 프로그램, 시스템 및 모듈 디렉토리가 있습니다.

일부 호스트에서는 CGI 모드에서 PHP를 실행할 때 사례 적으로 생각합니다.

RewriteRule ^(.*)$ index.php/$1 [L]

에게

RewriteRule ^(.*)$ index.php?/$1 [L]

당신의 htaccess에서. 기본적으로 사용할 수 있습니다 Kohana는 설정된 설정을 권장합니다, 간단히 교체합니다 index.php/$1 ~와 함께 index.php?/$1

이 mod_rewrite 규칙을 시도하십시오.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php index.php%{REQUEST_URI} [L]

기본적으로 .htaccess가있는 OSX에서 "Forbidden Error"403을받는 사람들의 경우 .htaccess의 첫 번째 줄로 추가하십시오.

옵션 +followsymlinks

Kohana 3.2에는 다른 협약이 있습니다. Kohana_url을 보면 다음 기능 서명을 찾을 수 있습니다.

public static function site($uri = '', $protocol = NULL, $index = TRUE)

여기서 $ index가 기본적으로 true입니다. $ index false를 전달하면 index.php 참조가 제거됩니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top