문제

I want to load contents of http://www.example.com/store/index whenever someone visits http://www.example.com/ without changing the URL. I tried the following URL and it doesn't work. Please help. Am I missing something very basic?

RewriteRule / /store/index [R=301,L]

도움이 되었습니까?

해결책

You can use this rule in your root .htaccess:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+store/index[?\s/] [NC]
RewriteRule ^ /? [R=301,L]

RewriteRule ^/?$ /store/index [L]
  • You need to match ^/?$ to make sure you're only rewriting home page
  • You must not use R flag to avoid URL changing in browser
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top