I've read this and this seems too long for my request.
And tried Redirect /index.php /index2.php
but it didn't work (Internal Server error)
What I want is to redirect some of my php files to index. For example, I've my index file as
header.php
content.php
footer.php
and I want to redirect direct access to this files to index.php. Is it possible with htaccess or any other way?
mysite.com/index.php OK mysite.com/header.php redirect to 404 or index or something else.
Try:
RewriteEngine On
RewriteRule ^(header|content|footer)\.php - [L,R=404]
or
RewriteEngine On
RewriteRule ^(header|content|footer)\.php index.php [L,R=301]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With