1

I am trying to remove the trailing index.php on my main site using .htaccess file and the following code....

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.(html?|php[45]?|[aj]spx?)\ HTTPS/
RewriteRule index\.(html?|php[45]?|[aj]spx?)$ https://www.gekkodev.com/%1 [R=301,L]

But of course it is still not working! I think the problem is my ssl certificate as that code has worked fine on lots of other sites

Any ideas would be greatly accepted! Many thanks.

  • Phillip
1
  • What is it doing instead of working? Is it redirecting incorrectly? Is it not rewriting at all? What example input URL are you using? Commented May 6, 2013 at 1:24

2 Answers 2

3

Your RewriteCond is taking entirely the wrong approach. An HTTPS request is just an HTTP request wrapped in SSL/TLS security - it will not contain the string HTTPS in the request line, which is what you are checking for.

If you want the rule only to apply to HTTPS requests, just use the %{HTTPS} variable, as listed in the documenation:

RewriteCond %{HTTPS} on

(I've seen a lot of rewrite rules testing %{THE_REQUEST} recently, and I'm not sure why, as it should really only be used as a last resort when nothing else can work.)

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

Comments

0

Sorted this is how I have done it!

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule index\.(html?|php[45]?|[aj]spx?)$ https://www.gekkodev.com/%1 [R=301,L]

Cheers IMSoP

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.