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
基础教程推荐
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- php中的foreach复选框POST 2021-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- php中的PDF导出 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- Web 服务器如何处理请求? 2021-01-01
