0

So I struggled a bit with Apache's mod_rewrite, but finally managed to configure(yes) and understand it(maybe?).

When the user goes to /index they are showed the /index.php page and the browser's url is http://example.com/index.

The user can also go to /index.php and the browser's url is http://example.com/index.php.

RewriteEngine On RewriteBase / RewriteRule ^index$ /index.php RewriteRule ^$ /index.php 

So my question is, how do I redirect a user from /index.php to only /index using only the server's configuration?

1
  • Who us your rewrite rules, please! Commented May 29, 2014 at 9:31

1 Answer 1

0

I'm not too sure what you mean by this.

in .htaccess to remove the extension .php you can use this:

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] 

I do believe this:

RedirectMatch 301 (.*)\.php$ http://www.example.com$1 

Should work for removing the .php

Maybe try that?

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

1 Comment

I am getting Internal server error.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.