elyfrank Posted June 1, 2012 Share Posted June 1, 2012 Hi guys, I have several urls that I would like to redirect using one line in my .htaccess example: http://www.example.com/example-1.html redirect to http://www.example.com/1.html I just pretty much want to take out the beguining (example-) of multiple urls Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/ Share on other sites More sharing options...
requinix Posted June 1, 2012 Share Posted June 1, 2012 Then you need mod_rewrite, not Redirect or RedirectMatch. RewriteEngine on RewriteRule ^example-(\d+)\.html$ /$1.html [L,R] [edit] I'm totally wrong: you can do it with RedirectMatch too. Check the manual page for an example how. Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350360 Share on other sites More sharing options...
elyfrank Posted June 1, 2012 Author Share Posted June 1, 2012 Requinix, Thank you for the quick response, however for some reason this is not working for me. (it doesn't redirect) this is my htaccess code Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] RewriteEngine on RewriteRule ^example-(\d+)\.html$ /$1.html [L,R] addtype application/x-httpd-php .html AddHandler x-httpd-php .html AddType application/x-shockwave-flash .swf Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350406 Share on other sites More sharing options...
requinix Posted June 1, 2012 Share Posted June 1, 2012 Try RewriteRule ^/?example-(\d+)\.html$ /$1.html [L,R] And remove the second RewriteEngine directive - one is enough. Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350420 Share on other sites More sharing options...
elyfrank Posted June 1, 2012 Author Share Posted June 1, 2012 Nope, didn't work Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350426 Share on other sites More sharing options...
requinix Posted June 1, 2012 Share Posted June 1, 2012 Can I assume the .htaccess is being interpreted? In what folder is the file and what URL are you trying? Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350427 Share on other sites More sharing options...
elyfrank Posted June 1, 2012 Author Share Posted June 1, 2012 The .htaccess and the files are in the same folder. I know the htaccess is working because all the lines above and below that are doing what they suppose to do. Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350437 Share on other sites More sharing options...
requinix Posted June 2, 2012 Share Posted June 2, 2012 And you're absolutely sure that you're going to http://www.example.com/example-1.html? Because I don't see anything else that could be the problem. How about using a RedirectMatch then? Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350451 Share on other sites More sharing options...
elyfrank Posted June 2, 2012 Author Share Posted June 2, 2012 How can I do it with redirect match? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350474 Share on other sites More sharing options...
requinix Posted June 2, 2012 Share Posted June 2, 2012 The manual page I linked you to has a very simple example of how. Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350522 Share on other sites More sharing options...
elyfrank Posted June 2, 2012 Author Share Posted June 2, 2012 Requinix, I used this RedirectMatch (example-)*\.html$ http://www.example.com$1.html And the output was: www.example.com.html At least it is recognizing the beginning of all my urls but I am missing something. Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350541 Share on other sites More sharing options...
requinix Posted June 2, 2012 Share Posted June 2, 2012 You are: a slash. Quote Link to comment https://forums.phpfreaks.com/topic/263497-redirectmatch-question/#findComment-1350664 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.