1

Well, I have tried to create a temporary redirect with wildcards:

http://www.example.com/index.php?topic=1578.0 to http://www.example.com/demo/showthread.php/1578

This is my htaccess:

RewriteEngine on
RewriteBase /

# Rules for topics:
RewriteRule ^index.php\?topic=([0-9\.0]+)$ /demo/showthread.php/$1

# Rule for homepage
RewriteRule ^index.php$ /demo/forum.php

My problem is with the rules for topics. Simply it does not redirect. Can you guide me the right direction?

1
  • I have read other question, I this is my merge, but I don't get it to work Commented Jul 30, 2014 at 0:21

1 Answer 1

2

A Query String Cannot be Matched Directly in the RewriteRule.

Use this instead:

RewriteCond %{QUERY_STRING} topic=([^&\s]+)
RewriteRule ^index.php /demo/showthread.php/%1? [L,R]
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you, I do know if I am so lost or my question is incorrect. And please apologies if it does. Is RewriteRule a redirection? because the idea is to send the browser to the new url. I am just reiceving the content of the new page but the url is not changing
I have changed (empirically) the [L] by [R] and now is working as a champ.
Yes, R will rewrite in the browser, whereas L is a transparent redirect. Will update the answer since this is what you want. Once you are happy with the redirect, you can change the R to R=301. Thank you for the green check mark. :)
+1 for on the spot A Query String Cannot be Matched Directly in the RewriteRule

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.