mod_rewrite重定向而不更改浏览器中的 URL


mod_rewrite to redirect without changing the url in the browser?

在网站的一般结构中是:

backend
- tralala
- tralala
- www
---- index.php
frontend
- tralala
- tralala
- www
---- index.php
common
- tralala
.htaccess

域例如www.mysite.com

我可以做一些事情在.htaccess中注册,以便当您转到www.mysite.com处理的文件frontend/www/index.php然后显示 url www.mysite.com 吗? 如果例如写www.mysite.com/admin/然后处理文件backend/www/index.php

在这种情况下,所有选项都

可能是其他选项,例如www.mysite.com/game/gta/(而不是game/gta/可以是任何东西),在这种情况下,为了使用以下参数(GET类型)标记文件frontend/www/index.php type=game&name=gta

尝试在 htaccess 文件中使用以下规则:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/admin/
RewriteRule ^ /backend/www/index.php [L]
RewriteCond %{REQUEST_URI} !^/(frontend|backend|common)
RewriteRule ^ /frontend/www/index.php