首页 > 解决方案 > 将每个 url 重定向到索引 .php,即使它存在于使用 .htaccess 的项目中

问题描述

我想将每个 url 重定向到 index.php 我的代码只在我的项目中不存在文件时将我带到 index.php。我想重定向 index.php 上的每个 url,即使文件中存在 url。

<IfModule php5_module>
   php_value default_charset "ISO-8859-1"
</IfModule>

<IfModule lsapi_module>
   php_value default_charset "ISO-8859-1"
</IfModule>

<IfModule mime_module>
  AddHandler application/x-httpd-ea-php54 .php .php5 .phtml
</IfModule>

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!index\.php).+)$ /index.php [L]

我也已经尝试过了

<IfModule mod_rewrite.c>

   RewriteEngine On

   RewriteCond %{REQUEST_FILENAME}  -f [OR]
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^(.*)$ index.php [L,QSA]

</IfModule>

标签: .htaccess

解决方案


推荐阅读