.htaccess 重写 URL 未正确显示? [英] .htaccess rewrite URL not showing correctly?

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

问题描述

当我写以下内容时,我想要它:

I want it so when I write the following:

http://boundsblazer.com/user/joe

它在内部处理页面:

http://boundsblazer.com/user/profile?usr=joe

但保留旧网址.但是,当我写:

But keeps the old URL. However, when I write:

http://boundsblazer.com/user/joe

网址变为:

http://boundsblazer.com/user/profile?usr=joe

我搜索了无数线程,没有人遇到我的问题.问题是当我写我的 URL 时,URL 会改变并使它看起来很难看.这是我的 .htaccess:

I have searched countless threads, and nobody is having the trouble I am. The problem is that when I write my URL, the URL changes and makes it look ugly. This is my .htaccess:

RewriteEngine on
RewriteRule ^user/([a-zA-Z0-9]+)$ http://boundsblazer.com/user/profile.php?usr=$1 [L,QSA]

有谁知道是什么导致了这个问题?

Does anyone know what could be causing the problem?

推荐答案

使用这个:

RewriteEngine on
RewriteRule ^user/([a-zA-Z0-9]+)$ /user/profile.php?usr=$1 [L,QSA]

问题在于您使用的是绝对 URL,而不是相对 URL,并且 mod_rewrite 正在执行重定向而不是重写.

The issue is that you are using an absolute URL, instead of a relative URL, and mod_rewrite is performing a redirect instead of a rewrite.

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

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