For example, visitor types www.website.com/index. I want to remove index and show this url www.website.com

In .htaccess wrote

RedirectMatch 301 /index https://www.website.com

As result instead of https://www.website.com get https:///www.website.com/?index with 404 error.

Please advice what is the correct way to redirect.

Some solution.

Did it not in .htaccess, but in php file.

This works

if( trim($_SERVER['REQUEST_URI']) == '/index' ){ 
header('Location: https://www.domain.com', true, 301 );
exit();
}

but may be some better solution?

up vote 3 down vote accepted

You probably can find all you need in the ExpressionEngine documentation which discusses this issue and provides some sample code.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.