Redirect everything to index.php(将所有内容重定向到 index.php)
问题描述
我试图通过分解 $_SERVER['REQUEST_URI'] 然后在结果之间切换来制作干净的 URL.
I'm trying to do clean URLs by exploding $_SERVER['REQUEST_URI'] and then switching between the results.
但是,一旦用户离开 index.php,我假设我需要将他们重定向回 index.php 以处理他们想要的 URL达到.我怎样才能做到这一点?
However, once a user goes outside index.php, I'm assuming I need to redirect them back to index.php in order to process the URL they want to reach. How can I accomplish this?
例如,如果用户访问 www.domain.com/home/johndoe/... 我想要 index.php (domain.com/index.php) 以便它可以通过 request_uri 处理 /home/johndoe/.
So for instance, if the user goes to www.domain.com/home/johndoe/... I'd like index.php (domain.com/index.php) to be hit so that it can process the /home/johndoe/ via request_uri.
推荐答案
.htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?param=$1 [QSA,L]
这篇关于将所有内容重定向到 index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将所有内容重定向到 index.php
基础教程推荐
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
