Apache .htaccess重写 [英] Apache .htaccess rewriting

查看:74
本文介绍了Apache .htaccess重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我想要实现的。

我要重写此URL
http://example.com?page=something
与此
http://example.com/something

I want to rewrite this url http://example.com?page=something to this http://example.com/something

这样,我可以$ _GET在网址
之后的任何内容$ _GET ['page'] ='某物'

such that i can $_GET whatever is after the url $_GET['page']= 'something'

我阅读过的所有教程都将其显示为http://example.com/page / something
所以我想知道是否有可能没有多余的 /

all the tutorials I've read show it like http: //example.com/page /something so i was wondering if it is possible without the extra "/"

// Update

//Update

这是我在.httaccess文件上拥有的内容

this is what i have on the.httaccess file


上的RewriteEngine RewriteRule ^(。*)/?$ index.php?page = $ 1 [L]

RewriteEngine on RewriteRule ^(.*)/?$ index.php?page=$1 [L]

但是当我做一个echo($ _ GET ['page']);我得到index.php

but when i do a echo($_GET['page'] ); i get index.php

推荐答案

虽然需要接受参数

RewriteRule ^(.*)/?$ index.php?page=$1 [L]

这篇关于Apache .htaccess重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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