为什么不这样阿帕奇modrewrite重写规则工作? [英] Why won't this Apache modrewrite RewriteRule work?

查看:107
本文介绍了为什么不这样阿帕奇modrewrite重写规则工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让阿帕奇mod-rewrite我的本地机器上运行。我运行OSX与PHP 5和Apachemod-rewrite模块使能。

I'm trying to get Apache mod rewrite to work on my local machine. I'm running OSX with PHP 5 and the Apache mod rewrite module is enabled.

我有一个名为本地主机的目录/〜杰森/ HFH /管理与各种PHP包括基于一个$ _GET变量调用。我想让用户类型(理论上)

I have a directory called localhost/~Jason/hfh/admin with various PHP includes called based on a $_GET variable. I want to let users type (in theory)

localhost/~Jason/hfh/admin/pages

和有URL留在地址栏,而什么获取显示为

and have that URL stay in the address bar, while what gets displayed is

localhost/~Jason/hfh/admin/?admin=pages

左右。

我已经创建,在/目录仁人家园位于.htaccess文件。在里面,我已经把这个MOD改写文本:

I've created a .htaccess file that sits in the /hfh directory. Inside, I've put this mod rewrite text:

RewriteEngine On
RewriteRule ^admin/([^/.]+)/?$ admin/?admin=$1 [L]

当我去到浏览器,键入

localhost/~Jason/hfh/admin/pages

我得到一个问题加载页面的错误,而Firefox说,哎呀,火狐不能出于某种原因加载这个页面。

I get a "Problem loading page" error, and Firefox says, "Oops. Firefox can't load this page for some reason."

谁能帮我算出这个?我有这样一个困难时期与正则表达式和mod-rewrite...

Can anyone help me figure this out? I have such a hard time with regex and mod rewrite...

推荐答案

到目前为止,答案似乎是:你不能在本地主机上使用mod-rewrite

So far the answer appears to be: you can't use mod-rewrite on localhost.

这篇关于为什么不这样阿帕奇modrewrite重写规则工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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