Stop WordPress from 301 redirecting /index.php to / -


i need able browse http://www.example.com/index.php, wordpress automatically 301 redirects http://www.example.com/.

is possible stop redirection homepage?

here .htaccess file:

# begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule>  # end wordpress 

the redirection occurs in redirect_canonical function. there filter applied redirect url before redirection occurs:

$redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url ); 

if hook filter should able disable redirection.

add_filter('redirect_canonical', function($redirect_url, $requested_url) {     if($requested_url == home_url('index.php')) {         return '';     } }, 10, 2); 

i verified working adding above filter theme's functions.php file. note filter must attached before redirect action fires placing filter in template file not work.


Popular posts from this blog