将所有内容重定向到index.php [英] Redirect everything to 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:
.htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?param=$1 [QSA,L]
这篇关于将所有内容重定向到index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!