简体   繁体   中英

Using Url Parameters in Rewrite Rule

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?

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM