0

I have a question about my .htaccess file, it won't show the file, when typing domain.com/about, instead of domain.com/about.php

Here is my .htaccess code (it works on localhost), i am using ubuntu and apache2 webserver

RewriteEngine on

# Rewrite /foo/bar to /foo/bar.php
RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]

# Return 404 if original request is /foo/bar.php
RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
RewriteRule .* - [L,R=404]
0

1 Answer 1

2

use

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Sign up to request clarification or add additional context in comments.

1 Comment

needed to use this sudo a2enmod rewrite command on my ubuntu server to get it to work, on ubuntu 14.04 Thanks!

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.