0

I know there are plenty of other questions similar to this one, i tried followinf some of those, but with no luck.

I have a website called test.com and i need, when someone seraches for test.com to show the content in test.com/home, without having home in the uerl.

My htaccess file at the moment looks like this:

RewriteEngine on
RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule    /(.*) home/$1    [L]
    RewriteRule    /home/(.*) /$1    [L,R=302]

RewriteOptions inherit

RewriteCond %{HTTP_HOST} ^test\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.test\.com$

but when i type test.com it shows a list of folders, not the content inside home.

What am i doing wrong?

thanks

2
  • Where is this htaccess located? Commented Sep 18, 2015 at 21:40
  • i'm using cpanel, and it is located in the public_html folder Commented Sep 18, 2015 at 21:42

1 Answer 1

1

You can simplify your rules to this in root .htaccess

RewriteEngine on
RewriteBase /

RewriteRule ^$ home/ [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!home/).+)$ home/$1 [L,NC]

Make sure to clear your browser cache before testing this.

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.