0

I want to redirect the root URL only excluding index.php which is in root folder. This is what i have so far:

RewriteEngine on
RewriteCond %{HTTP_HOST} website\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ http://website.com/redirect/ [L,R=301]
RewriteRule ^/index\.php$ - [L]

It still redirects the index.php file when manually entered!

1
  • What URL are you testing? Commented Jan 31, 2016 at 13:11

1 Answer 1

1

Please try the following:

RewriteEngine on

# Condition: Only match host 'website.com'
RewriteCond %{HTTP_HOST} ^website\.com$ [NC]

# Rule: If request is for root, redirect
RewriteRule ^$ http://website.com/redirect/ [R=302,L]

As you used 301 already, you may need to clear the cache for the browser to redirect properly.

Once you are happy, and would like to make the redirect permanent, change 302 to 301.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.