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


- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01