Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
616 views
in Technique[技术] by (71.8m points)

php - .htaccess rewrite URL not showing correctly?

I want it so when I write the following:

http://boundsblazer.com/user/joe

it internally processes the page:

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

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

http://boundsblazer.com/user/joe

the URL becomes:

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use this:

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...