기존 디렉토리를 IIS 또는 Apache의 매개 변수로 전달합니다.
-
19-09-2019 - |
문제
먼저이 URL을보십시오.
https://stackoverflow.com/questions/tagged/xoxoxo/
이 디렉토리는 존재하지 않지만 어떻게 든 stackoverflow는 해당 마지막 디렉토리를 기본 스크립트로 전달할 수 있습니다.
IIS 또는 Apache를 구성 할 수 있습니까? 어떻게?
해결책
이런 종류의 행동의 메커니즘을 호출합니다 Url-Lewriting 그리고 구현 될 수 있습니다 아파치 이랑 mod_rewrite
-헬리콘이있는 -모듈과 II Isapi_rewrite Lite (또는 Helicon이 제공하는 비없는 대안 중 하나) IIS 5.1 그리고 6 또는 Microsoft URL Rewrite 모듈 ~을 위한 IIS 7.
예를 들어 다음 설정은 기존 파일 또는 디렉토리에서 일치 할 수없는 모든 요청이 index.php
파일.
mod_rewrite
(.htaccess
문서 루트 디렉토리 또는 어딘가에 httpd.conf
)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR] // IF is file (with size > 0)
RewriteCond %{REQUEST_FILENAME} -l [OR] // OR is symbolic link
RewriteCond %{REQUEST_FILENAME} -d // OR is directory
RewriteRule ^.*$ - [NC,L] // DO NOTHING
RewriteRule ^.*$ index.php [NC,L] // TRANSFER TO index.php
Isapi_rewrite Lite (IIS 설정의 적절한 대화에서)
// uses same syntax as mod_rewrite
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Microsoft URL Rewrite 모듈 (당신의 web.config
문서 루트 디렉토리 또는 구성 트리의 Seome에서)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="MatchExistingFiles" stopProcessing="true">
<match url="^.*$" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" pattern="" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" pattern="" ignoreCase="false" />
</conditions>
<action type="None" />
</rule>
<rule name="RemapMVC" stopProcessing="true">
<match url="^.*$" />
<conditions logicalGrouping="MatchAll" />
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
제휴하지 않습니다 StackOverflow