Question

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]

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top