如何使用虚拟文件夹结构网址 [英] How to use virtual folder structure url

查看:86
本文介绍了如何使用虚拟文件夹结构网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的网址

  http://www.abcdef.com/somthing.php 

我想使用相同的文件内容,但使用不同的url格式

  http://www.abcdef.com/exp/go/to/123 

为此我需要修改php或htaccess文件吗?

解决方案

.htaccess文件



例如:

  RewriteEngine on 
重定向^ / exp / go / to / 123 $ /somthing.php [L]

主要之所以使用 / exp / go / to / 123 URL结构,是因为不同的元素可以用作加载页面的变量,在这种情况下,您可以使用:




上的

  RewriteEngine重定向^ / exp / go / to /([0-9] +)$ /somthing.php:id=$1 [L] 

将从网址中删除123,并将其作为ID参数传递给someting.php。 p>

I have url like this

http://www.abcdef.com/somthing.php

i want use same file content but different url format like this

http://www.abcdef.com/exp/go/to/123

for this where i need to modify either php or htaccess file?

解决方案

The .htaccess file

for your example you'd use:

RewriteEngine on
Redirect ^/exp/go/to/123$ /somthing.php [L]

The main reason you'd use the "/exp/go/to/123" URL structure is because the different elements can be used as variables to load the page in which case you could use:

RewriteEngine on
Redirect ^/exp/go/to/([0-9]+)$ /somthing.php:id=$1 [L]

which will take the 123 off the url and pass it to the someting.php as an ID parameter.

这篇关于如何使用虚拟文件夹结构网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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