최근에 .htaccess와 URL 재 작성으로 도왔으며 최근까지는 잘 작동했습니다. 기본적으로 모든 URL을 index.php로 리디렉션 한 다음 URL을 처리하고 올바른 내용을 표시합니다. 그래서 만약 내가 작동하고 올바르게 표시 http://www.example.com/blog/index.html
입력하십시오. 하지만 http://example.com/blog/
을 입력하면 404 오류가 발생합니다 ... 아래의 경우 .htaccess 코드와 PHP 코드를 모두 입력해야합니다..htaccess가 특정 URL을 리디렉션하지 않습니다.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*\.html)$ index.php/$1/ [L]
과 PHP :
if(($_SERVER['REQUEST_URI'] == '/') || ($_SERVER['REQUEST_URI'] == '/index.php') || ($_SERVER['REQUEST_URI'] == '/index.html'))
{
//Looks like we are accessing the root
$this->controller = $this->config['default'];
} else {
$this->uri = explode('/', str_replace('.html', '', $_SERVER['REQUEST_URI']));
$this->controller = $this->uri[1];
if(isset($this->uri[2]))
{
$this->action = $this->uri[2];
}
}
어떤 도움을 주시면 감사하겠습니다, 감사합니다!
같이해야합니까? –
죄송합니다, 아파치에 의해 생성되었습니다 –
스크립트에서 'http : // www.example.com/blog/index.html'과'index.php'라는 2 개의 다른 파일을 호출하는 것처럼 보입니다. –