做清洁的U​​RL与htaccess的 [英] making clean url with htaccess

查看:118
本文介绍了做清洁的U​​RL与htaccess的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让干净的URL与htaccess的
我有一个profile.php页面,我得到用户的域名,以显示他的网页
现在如果用户例如打www.XXXX.com/domain我将显示他的主页
它相当于www.XXXX.com/profile.php?id=domain没有htaccess文件 我用这个code及其工作很细

I am trying to make clean url with htaccess
I have a profile.php page and I get user domain name to display his page
now if the user for example hit www.XXXX.com/domain I will display his main page
it is equivalent to www.XXXX.com/profile.php?id=domain without htaccess file I used this code and its working very fine

Options +FollowSymLinks
RewriteEngine On
RewriteCond %(SCRIPT_FILENAME) !-d
RewriteCond %(SCRIPT_FILENAME) !-f
RewriteRule ^(\w+)$ ./profile.php?id=$1
RewriteRule ^(\w+)/$ ./profile.php?id=$1

现在我试图让网页ID和用户想要显示的看法,但它没有工作

now I am trying to get page id and the view that the user wants to display but it didn't work

请注意页面ID和观点是可选的值,如果没有在URL中,我将显示主页

note page id and view are optional values , if didn't found in the url I will display the main page

我要的URL看起来像www.XXXX.com/domain/pageid/view, 这相当于www.XXXX.com/profile.php?id=domain&pid=pageid&v=view

I want the url to look like www.XXXX.com/domain/pageid/view , which is equivalent to www.XXXX.com/profile.php?id=domain&pid=pageid&v=view

推荐答案

这应该做到这一点:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %(SCRIPT_FILENAME) !-d
RewriteCond %(SCRIPT_FILENAME) !-f
RewriteRule ^(\w+)\/(\w+)\/(\w+)\/?$ ./profile.php?id=$1&pid=$2&v=$3

这篇关于做清洁的U​​RL与htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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