如何通过index.PHP重新路由所有PHP页面请求?
我的.htaccess如下:
Options +FollowSymLinks IndexIgnore */* #Turn on the RewriteEngine RewriteEngine On # Rules RewriteCond %{REQUEST_FILENAME} !-f RewriteRule !.*\.(js|ico|gif|jpg|png|css|pdf)$index.PHP%{REQUEST_URI} [L]
基本上,我试图模仿.NET主页. index.PHP具有站点页眉/页脚.
它将404重定向到index.PHP.如何使所有请求重定向到PHP页面(index.PHP本身除外)?
这种方法有什么性能问题(不想使用框架)?
这是我使用的(并已使用年龄):
<IfModule mod_rewrite.c> # 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] </IfModule>
正如评论所示,它将路由不是实际文件的每个请求到index.PHP