1

I have a large list with redirected url's and need a global rule for url's with languages. For example. All /fr/ .jsp files i need to redirect to /fr/ and all /es/ files with extension .jsp to /es, i tried so with help from other stackoverflow topics but this don't work:

RewriteCond %{QUERY_STRING} ^/es/*.jsp$
RewriteRule ^es/$ /es [R=301,L]
iJohny
  • 13
  • 3

1 Answers1

2

This one rule would work for both requirements:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(es|fr)/.+?\.jsp$ /$1 [R=301,L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(ru|de)/.+?\.jsp$ /en [R=301,L,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Can i add here also url redirect for language which don't exist on new website? For example Russian /ru/.jsp files to /en? I tried from here to solve problem: http://stackoverflow.com/questions/10064603/htaccess-redirect-to-language-subfolder – iJohny Jun 25 '14 at 07:25
  • Yes sure, see updated answer. Now `/ru/*.jsp` OR `/de/*.jsp` goto `/en/` – anubhava Jun 25 '14 at 07:28
  • hmmm my other redirects are now ignored, it's possible to add rule if nothing exist then this rules? Because there are some specific redirects like /es/about-us.jsp to /es/about-us – iJohny Jun 25 '14 at 07:31
  • Yes see edited code and also you can have these rules below those rules – anubhava Jun 25 '14 at 07:32
  • This was before in my htaccess file "RewriteCond %{REQUEST_FILENAME} !-f", but specific url redirect still don't work, i tried this extra rules to move bofore your code and after your code, but it's not correct, can i do something like if request? – iJohny Jun 25 '14 at 07:39
  • Can you post your complete .htaccess in your question for investigation. – anubhava Jun 25 '14 at 07:40
  • This is a joomla htaccess file, there is firstly joomla standard data then my "Redirect /es/something.jsp" /es/someting and then your code, it think here will be long file if i post it. – iJohny Jun 25 '14 at 07:43
  • Put it on pastebin and provide me a link. – anubhava Jun 25 '14 at 07:44
  • Oh it says paste removed. – anubhava Jun 25 '14 at 07:57
  • You need to insert my suggested line just below `## End - Custom #Redirects` line. – anubhava Jun 25 '14 at 08:52
  • It's really quite a job to take an htaccess question from start to finish!... +1 :) – zx81 Jun 25 '14 at 09:00
  • Thanks, Yes it is really challenging sometimes to extract correct info from OP. – anubhava Jun 25 '14 at 09:01