I've an problem with URL-spinning inshtaccess. Here's .htaccess file:

RewriteEngine On
RewriteBase /community/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^view-all-results$ forums/index.php?view=view-all-results [R=302]
RewriteRule ^view-all-results/$ forums/index.php?view=view-all-results [R=302]

I have to rewrite url like "/community/view-all-results?u=2" to "community/forums/index.php?view=view-all-results&u=2". But based on the above rule I'll get "community/forums/index.php?view=view-all-results".

I attempted to alter RewriteRule to

RewriteRule ^view-all-results?(.*)$ forums/index.php?view=view-all-results&$1 [R=302]

However it does not work correctly. Still it rewrites Hyperlink to "community/forums/index.php?view=view-all-results".

After I transformed rule(put + rather than *):

RewriteRule ^view-all-results?(.+)$ forums/index.php?view=view-all-results&$1 [R=302]

I have got URL like "community/forums/index.php?view=view-all-results&s". And So I do not understand this behavior.((

I'll be very appreciated for just about any suggestions.

The miracle flag is in the docs: [cde], that will add the initial querystring for your url.

Normal matching is just done from the path, not agains the querysting, which you'd get in the miracle variable [QSA]). Matching this variable could be completed in a %{QUERY_STRING} condition. You might append this variable towards the resulting url, but RewriteCond is infinitely more userfriendely here.

Give mtss is a try...

QSA

Essentially the very first 1 / 2 of a RewriteRule does not match from the QUERY_STRING, which means you second to example won't ever match against it. The primary factor the first code didn't have was the QSA flag, which informs it to pass through the QUERY_STRING it receives together with the recently produced QUERY_STRING. I additionally removed the R=302, when i assume you wouldn't want the Hyperlink to change.

Edit: Oh, I additionally combined the guidelines by looking into making the trailing slash optional.