이미 CheckSpelling On을 사용하고 있으며 제대로 작동하는 URL 대소 문자를 구분하지 않고 만들고 싶습니다. 병렬에서 나는 또한 내가 적용한 URL에서 확장을 제거하고 싶었습니다.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
그것은 또한 작동했습니다. 그러나 둘 다 모두 작동하지 않습니다. htaccess에 둘 다 유지하면 오류 300 ( "Multiple Choices")이 발생하기 시작합니다.
당신은 자신을 어렵게 만들고 있습니다. PHP에서 기본 라우팅을 수행하면 더 쉬울 것입니다. index.php
디렉토리가 아니고 파일이 아니거나 php 파일 인 것은 무엇이든 보내십시오 .
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} (?>.*)(?<=\.php) [NC]
RewriteRule ^(?!index\.php$). index.php [NS,L]
의 상단에서 index.php
다음과 같이하십시오.
<?php
$url = explode('?', $_SERVER['REQUEST_URI'], 2);
$url = substr($url[0], 1);
if ($url) {
$url = strtolower($url) . '.php';
if (preg_match('@^[^./][^/]*(?:/[^./][^/]*)*$@', $url) && file_exists($url)) {
. # does not contain dotfiles, nor `..` directory traversal, so is a php file below web root
include $url;
}
else {
# virtual URL doesn't exist,
# set 404 response code header and serve a default page
include '404.php';
}
exit;
}
# no virtual URL, continue processing index.php
소문자 URL이 포함 된 rel=canonical
각 페이지 에 를 추가합니다 <head>
(쿼리 문자열이 다시 추가됨). 중복 콘텐츠에 대한 불이익을받지 않도록합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다