In .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} =sdmon=software_download/software1.exe
RewriteRule ^index.php$ http://download.domain.com/software1.exe? [L,R=301]
RewriteCond %{QUERY_STRING} =sdmon=software_download/software2.exe
RewriteRule ^index.php$ http://download.domain.com/software2.exe? [L,R=301]
</IfModule>

These rules redirect http:www.domain.com/index.php?sdmon=software_download/software1.exe to http:www.domain.com/software1.exe ....

My question is : How to combine the 2 sets of rules into a single one.

link|improve this question
Is the second rule supposed to go to software2.exe, not just software2? – Shane Madden Jan 23 at 4:00
sorry for missing exe . ive fixed that. Have u got any idea? – Jeriff Cheng Jan 23 at 5:13
feedback

1 Answer

Try this:

RewriteCond %{QUERY_STRING} ^sdmon=software_download/software(\d+)\.exe$
RewriteRule ^index.php$ http://download.domain.com/software%1.exe? [L,R=301]

That'll work for software1, software5600, and anywhere else in between.

Edit:

For any exe name, try this:

RewriteCond %{QUERY_STRING} ^sdmon=software_download/([^/\.]+)\.exe$
RewriteRule ^index.php$ http://download.domain.com/%1.exe? [L,R=301]
link|improve this answer
thanks! What if hello.exe hi.exe ladygaga.exe ? I mean, not the number variation, but different exe name. O(∩_∩)O~ – Jeriff Cheng Jan 23 at 7:52
@Chang See edit. – Shane Madden Jan 23 at 15:48
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.