php - .htaccess 重写/到 index.html,所有其他到 index.php

标签 php .htaccess

我想使用 .htaccess 将 url 重写到我的网站:

如果 url 是 http://mydomain.comhttp://mydomain.com/ index.html 将处理请求,所有其他 url 将转到 index.php

请帮忙!

最佳答案

像这样的东西会在内部将任何没有路径或只有尾部斜杠的请求重定向到 index.html,并将其他所有内容重定向到 index.php,并将路径作为参数。

RewriteEngine  on
RewriteRule ^$ index.html
RewriteRule ^(.*)$ index.php?$1 [L]

关于php - .htaccess 重写/到 index.html,所有其他到 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16631861/

相关文章:

apache - 如何在隐藏扩展名时忽略与文件同名的目录

php - Symfony composer update "freeze"更新依赖

html - 在静态 html 着陆页中路由

css - Internet Explorer 模式重写

.htaccess - 如何重定向到不同的域和不同的文件夹?

php - Laravel 路由和 .htaccess 文件不适用于 1and1 托管

php - MySQL 数据库中的范围 slider 和值

php - 0A 在使用 PHP 检索时添加到 BLOB

php - CodeIgniter 3 + SQL Server + Windows 10

php - PDO 方法可以失败并且不抛出 PDOException 吗?