A
A
Alexander Konovalov2019-02-04 20:45:11
htaccess
Alexander Konovalov, 2019-02-04 20:45:11

How to set up a redirect to pages without .php?

Hello! I have configured to display the address of pages without .php. But at the same time, if you add .php to the address, the page will still open. How to make pages with .php flip to without .php?

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-02-04
@Huf

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} " /(index\.php|([^?]*)\.php)"
RewriteRule ^ /%2 [R=301,L,NE]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question