-3

But I also want that every page redirect to page.php for example:

me -> me.php

blog -> blog.php

test -> test.php

I don't know if redirect is the right word because what I want is that we call X and it open X.php but don't show the extension (.php)

Hope everybody can help me.

Thanks

0

1 Answer 1

0

Create a .htaccess file and put this in it:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

That way, URLs such as domain.com/blog, it will silently append .php to the file name (ie loading blog.php).

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

2 Comments

@João Plus Don't work says nothing. Explain why it doesn't work, please. Did you get an error, the rule was not applied, what?
The rule was not applied. I did what Supericy said but when try to go to index it doesn't show the file index.php. The error is the usual 404.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.