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
1.2k views
in Technique[技术] by (71.8m points)

apache - Rewrite GET Query String using .htaccess

I want to Rewrite my GET Query String from this -

http://www.example.com/verify.php?key=547b52f2b5d20d258e62de1e27b55c

to this

http://www.example.com/verify/547b52f2b5d20d258e62de1e27b55c

I am using the following rule but it does not seem to work -

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(([A-Za-z0-9-]+/)*[A-Za-z0-9-]+)?$ $1.php

RewriteRule    ^[A-Za-z-]+/([A-Za-z0-9-]+)/?$    verify.php?key=$1    [NC,L]
See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Use the following:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET /verify.php?key=([^s&]+) [NC]
RewriteRule ^verify.php$ /verify/%1? [R=301,L]

RewriteRule ^verify/([^/]+)/?$ /verify.php?key=$1 [NC,L]

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

...