dongpi3237 2013-09-08 10:16
浏览 37
已采纳

将域后的所有内容路由到index.php?

I'm using this .htaccess file but it doesn't work:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^(.*)$ /index.php?$1 [R,L] 

What I see in Apache error log is [Error: Over 10 times of redirecting internally]. I added the flag 'L' in RewriteRule but it doesn't stop after the first time matching the rewrite rule.

  • 写回答

1条回答 默认 最新

  • duandan9680 2013-09-08 10:38
    关注

    If you are running v2.2.16+ then use FallbackResource, see: https://httpd.apache.org/docs/2.2/mod/mod_dir.html#fallbackresource

    FallbackResource /index.php
    

    The alternative is to use mod_rewrite and the code should be as follows:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?