hi i have this code : RewriteEngine On RewriteRule ^rs([0-9][0-9][0-9])/([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])/(.*)$ http://xXx:XxX@rs$1.rapidshare.com/files/$2/$3 Code (markup): i want to redirect urls like these : http://mysite.com/rs6l32/91313738/Ashampoo_AntiSpyWare_2.01_abu137_.rar Code (markup): to : http://xXx:XxX@rs6l32.rapidshare.com/files/91313738/Ashampoo_AntiSpyWare_2.01_abu137_.rar Code (markup): i have a problem : the data after RS in rewrite rule will change from letter to number and also the length of them change from link to link look at these : http://rs354c3.rapidshare.com/files/101811798/Ashampoo_Photo_Commander_abu137_.rar http://rs314tl.rapidshare.com/files/101812754/Ashampoo_Photo_Optimizer_abu137_.rar http://rs3tl2.rapidshare.com/files/101790462/Ashamp00-Win0ptimizerv5.02_abu137.rar Code (markup): in the first rule will be like : RewriteRule ^rs([0-9][0-9][0-9][a-z][0-9])/([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])/(.*)$ Code (markup): and others will change can anyone suggest me the correct code ? thanks in advance
Rather than writing things like this: RewriteRule ^rs([0-9][0-9][0-9])/([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])/(.*)$ http://xXx:XxX@rs$1.rapidshare.com/files/$2/$3 Code (markup): You can write: RewriteRule ^rs([0-9]{3})/([0-9]{9})/(.*)$ http://xXx:XxX@rs$1.rapidshare.com/files/$2/$3 Code (markup): Which makes things much more readable. You can add numbers and letters inside square brackets like this: RewriteRule ^rs([a-z0-9]{3})/([0-9]{9})/(.*)$ http://xXx:XxX@rs$1.rapidshare.com/files/$2/$3 Code (markup): Which will allow the letters and numbers to be matched in any order. You can also put ranges in the curly brackets like this: RewriteRule ^rs([a-z0-9]{2,3})/([0-9]{7,10})/(.*)$ http://xXx:XxX@rs$1.rapidshare.com/files/$2/$3 Code (markup): Which will match two or three letters and numbers followed by a slash and then between 7 and 10 numbers. I put together an Apache regex guide a while ago that may be of some use to you.