0

I have a bit of an interesting issue, I have a QR code that upon being scanned sends users to the address below:

enzymedica.org/ls/27210 

(This is just the DEV site by the way the real one is .com)

Then I have it successfully redirecting to this address:

enzymedica.org/education/digestive/digest-gold.html

Now here is where the problem comes into play, if this is all it did then we wouldn't have a problem, however when the QR code gets scanned it tacks on a "?" and then a number like 0000 after it.

So in reality the url that you get sent to is more or less like this:

http://www.enzymedica.org/ls/27210?0000

and upon redirecting you get this:

http://www.enzymedica.org/education/digestive/digest-gold.html?0000

So I need some way to get the url rewritten to end at ".html" and not show anything after it.

4

1 に答える 1

1
Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+\.html)\?.+ [NC]
RewriteRule ^ %1? [R=301,L]

上記はeducation/digestive/anythinghere.htmlクエリ文字列があるかどうかを確認し、ある場合はクエリ文字列なしでリダイレクトします。

または、その URL の正確なリダイレクトが必要な場合は、次を使用できます。

RewriteCond %{QUERY_STRING} !^$
RewriteRule ^(education/digestive/digest-gold\.html)$ /$1? [R=301,NC,L]

または、レベルでそれを排除したい場合ls/id:

RewriteCond %{QUERY_STRING} !^$
RewriteRule ^ls/([0-9]+)/?$ /ls/$1? [R=301,NC,L]
于 2013-09-19T19:36:33.273 に答える