Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess Redirect One File to Another

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.

like image 681
Degauser Avatar asked Apr 20 '14 16:04

Degauser


1 Answers

Try:

RewriteEngine On
RewriteRule ^(header|content|footer)\.php - [L,R=404]

or

RewriteEngine On
RewriteRule ^(header|content|footer)\.php index.php [L,R=301]
like image 52
Jon Lin Avatar answered Oct 13 '22 03:10

Jon Lin