mod_rewrite用户ID错误 [英] mod_rewrite user id error

查看:51
本文介绍了mod_rewrite用户ID错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是重写URL的新手,想知道我将如何重写

I'm new to rewriting urls and wanted to know how i would rewrite

从这里 /profile/4

From this /profile/4

对此 /profile.php?id=4

To this /profile.php?id=4

到目前为止,我有此规则

I have this rule so far

RewriteRule ^profile/([0-9]+)/?$ profile.php?id=$1

但它会在浏览器中显示

Firefox已检测到服务器正在以永远无法完成的方式重定向对此地址的请求.

它在浏览器地址栏中显示/profile/4/index.php,这是错误的.

It displays /profile/4/index.php in the browser address bar which is incorrect.

.htaccess文件

<Files .htaccess>
order allow,deny
deny from all
</Files>

Options +FollowSymlinks
RewriteEngine on
#ErrorDocument 404 /test.php
DirectoryIndex test.php
RewriteRule settings editProfile.php
RewriteRule update update.php
RewriteRule home test.php
RewriteRule ^profile/([0-9]+)/?$ profile.php?id=$1

推荐答案

您就在那里.尝试改用此

You are pretty much there. Try using this instead

RewriteRule ^profile/(.*)$ profile.php?id=$1

我在网上发现了这个很好的免费资源,可以在发布之前帮助您测试您的重写规则他们到您的现场.这可能对将来有所帮助.不过,您的规则似乎应该可以正常运行.问题一定在其他地方.

I found this good free resource online to help you test your rewrite rules before you post them to your live site. This may help for the future. It looks like your rule should work as you have it posted though. The problem must be somewhere else.

这篇关于mod_rewrite用户ID错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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