Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

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

1 Answer 1

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]
share|improve this answer
    
thanks! What if hello.exe hi.exe ladygaga.exe ? I mean, not the number variation, but different exe name. O(∩_∩)O~ –  user107937 Jan 23 '12 at 7:52
    
@Chang See edit. –  Shane Madden Jan 23 '12 at 15:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.