Rerouting all php requests through index.php

前端 未结 4 1762
误落风尘
误落风尘 2020-11-28 07:20

How can I reroute all requests for php pages through index.php?

My .htaccess is as follows:

Options +FollowSymLinks
IndexIgnore */*
#Turn on the Rewr         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-28 07:36

    Here's what I use (and have used for ages):

    
        # Redirect /index.php to / (optional, but recommended I guess)
        RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php
        RewriteRule ^index.php/?(.*)$ $1 [R=301,L]
    
        # Run everything else but real files through index.php
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php/$1?%{QUERY_STRING} [L]
    
    

    As the comments suggest it will route every request that isn't an actual file to index.php

提交回复
热议问题