帮助与动态URL的mod_rewrite规则 [英] Help with mod_rewrite rule for dynamic url

查看:122
本文介绍了帮助与动态URL的mod_rewrite规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

唉.. mod_rewrite的让我觉得自己很傻。我只是还没有包裹着我的大脑左右呢。 :/

Ugh.. mod_rewrite makes me feel stupid. I just haven't wrapped my brain around it yet. :/

我有这个网址:

http://example.com/a/name/

...我想点这里:

http://example.com/a/index.php?id=name

...其中名称是什么,是越来越传递到的index.php ID 参数。

...where name is what is getting passed to index.php as the id argument.

什么我已经试过的结果无论是404还是500 ..:(

Anything I've tried results in either a 404 or a 500.. :(

推荐答案

要开始你了:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !index.php
RewriteRule ^/?a/([^/]+)/?$ /a/index.php?id=$1 [QSA,L]

如果一次重写教程不为你工作,尝试另一种

If one rewrite tutorial doesn't work for you, try another.

编辑:排除的index.php 按浓汤的建议

excluded index.php as per Gumbo's suggestion

这篇关于帮助与动态URL的mod_rewrite规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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