URL重写 - 在URL中删除目录名 - PHP [英] URL Rewrite - remove directory name in the URL - PHP

查看:107
本文介绍了URL重写 - 在URL中删除目录名 - PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想重写URL是这样的:

I want to rewrite the url like this:

HTTP://localhost/public/viewbusiness.php S = cyberbooger-网络服务

HTTP://localhost/viewbusiness.php S = cyberbooger-网络服务

从而消除了URL目录名。 你是否注意到,在 viewBusiness.php 位于公开目录。

thus removing the directory name in the url. You noticed that the viewBusiness.php is located in the public directory.

我的应用程序不遵循MVC架构,而不是使用框架。这是我做的事情,因为我正在学习PHP的一个应用程序。

My application is not following the MVC architecture, and not using a framework. This is a application I am doing right as I currently studying PHP.

我的文件夹结构是这样的:

My folder structure is like this:

- /应用

- /公共

- 的index.php

-- index.php

谁能帮助我?太谢谢你了!

Can anyone help me? Thank you so much!

推荐答案

尝试:


<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(\w+)/(\w+)$ $1/public/$2 [QSA]
</IfModule>

这篇关于URL重写 - 在URL中删除目录名 - PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆