llanato
llanato

Reputation: 2491

htaccess Rewrite Rule Not Redirecting?

I have the below rewrite rule and for the life of me can't figure out why it's not working, there are no errors in any logs and nothing being displayed on screen, I'm stumped.

It takes a session token and passes it through the url.

Options +FollowSymlinks
RewriteEngine On

RewriteRule ^/\?action=logout;(.*)$ /forum/index.php?action=logout;$1 [NC,L]

I've also tried this with no luck, no errors or anything to suggest an issue.

RewriteCond %{QUERY_STRING} ^action=logout
RewriteRule ^/\?action=logout;(.*)$ /forum/index.php?action=logout;$1 [L,R=301]

Upvotes: 1

Views: 34

Answers (1)

Justin Iurman
Justin Iurman

Reputation: 19016

Using QUERY_STRING is a good start.
Anyway, you now need to match / or /index.php in your rule.

Also, since you're passing the same query string, you don't need to capture a part of it. You can use QSA flag instead.

RewriteCond %{QUERY_STRING} ^action=logout [NC]
RewriteRule ^/?(?:index\.php)?$ /forum/index.php [L,NC,R=301,QSA]

If you want a silent redirect (internal rewrite), just remove R=301 flag

Upvotes: 1

Related Questions