모든 URL을 "/"로 어떻게 다시 작성하려면?
-
05-07-2019 - |
문제
서버 : 아파치
다음과 같은 방식으로 URL을 다시 작성하려고합니다.
http://website.com/index.html
나는 그것이로 리디렉션되기를 원한다 :
http://website.com/
기본적으로 index.html로드하고 싶지만 URL에 표시되지 않습니다. 나는 또한 다른 이름을주고 싶지 않습니다. 나는 찾고 있지 않다 /index.html 될 것입니다 /인덱스
또한 다음과 같은 데이터를 얻으려고 노력하고 있습니다.
http://website.com/index.html?id=0&name="fred"
다시 작성하려면 :
http://website.com/?id=0&name="fred".
.htaccess 파일을 사용하지 않는 솔루션이있는 경우 괜찮습니다.
해결책
나는 이것이 효과가 있다고 생각한다 :
RewriteEngine on
RewriteRule ^index\.html(.*)$ /$1 [R=permanent,L]
이것은 시작하는 모든 요청을 리디렉션합니다 /index.html
간단히 "/
"그리고 나오는 주장을 보존 할 것입니다 index.html
다른 팁
.htaccess 파일의 경우 :
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\ /index\.html
RewriteRule ^index\.html$ / [L,R=301]
제휴하지 않습니다 StackOverflow