How to use virtual folder structure url

痴心易碎 提交于 2019-12-12 00:33:23

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/28742008/how-to-use-virtual-folder-structure-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!