How do I remove index.php/html from the url

I am running into a problem concerning the mod_rewrite.

RewriteCond %{THE_REQUEST} /index\.[php|html] [NC]
RewriteRule (.*)index\.[php|html]$ /$1 [R=301,L]

The idea is to get both domain.com/index.php and domain.com/index.html redirected to domain.com. My attempts do not seem to work. The above code is one of my attempts.

It would be great if you could help me out!

Answers


Your regex is incorrect You need to use ( ) instead of [ ].

Use this rule:

RewriteCond %{THE_REQUEST} /index\.(php|html?) [NC]
RewriteRule ^(.*?)index\.(php|html?)$ /$1 [R=301,L]

Need Your Help

How can I parallelize Ants signJar task

java ant jar-signing

We are signing a lot of jar files in our build. At the moment it takes between 60-80% of the total build time, changing it from 15 min to 45+ min. We are therefore very interested in speeding up the

Ruby Net::SMTP - Send email with bcc: recipients

ruby email-integration bcc

I would like to use Ruby Net::SMTP to send email. The routine