Pergunta

I have read a lot of suggestion, article but i could not fixed my problem. Here is my Url :

us/my-blog?catid=1&id=404:my-thought-of-the-day-problem-of-traditional-education ja/resources?id=366:video-clip

I want to redirect this URL to static URL. I have tried with .htaccess Like this :

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_URI} !^/index.php

RewriteCond %{REQUEST_URI} (/|.php|.html|.htm|.feed|.pdf|.raw|/[^.]*)$ [NC]

RewriteRule (.*) index.php

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

Redirect 301 /tw/en/investment-opportunities/ultimate-banking-how-to-create-your-own-bank http://takeshiyashima.com/tw/investment-opportunities/ultimate-banking-how-to-create-your-own-bank

Above URL Fixed and working now but the top URL i have mentioned are not working. I need help.

Foi útil?

Solução

Please, give a more clear example and post the right link, as it is not clear if there is any symbol before 'ja/resources' and if it's a part of the link at all.

As I understand you want to take only the part: 'my-thought-of-the-day-problem-of-traditional-education'

and redirect to: 'http://takeshiyashima.com/tw/investment-opportunities/my-thought-of-the-day-problem-of-traditional-education' If it's true here is the possible rule:

us/my-blog?catid=1&id=404:my-thought-of-the-day-problem-of-traditional-education

RewriteRule ^\/?us/my-blog\?catid=\d+id=\d+\:(.*) http://takeshiyashima.com/tw/investment-opportunities/$1 [R=301,L]

Not tested and can be made shorter. If you give more details to the example I will try to help.

Update according to your comment

For ja/resources?id=366:video-clip to takeshiyashima.com/ja/resources it is:

RewriteRule ^\/?ja/resources.* http://takeshiyashima.com/ja/resources [R=301,L]

For 'us/my-blog?catid=1&id=404:my-thought-of-the-day-problem-of-traditional-educatio‌​n', everything is clear, but I see no logic in '/1-my-thought', we have to have a clear pattern. If you say that you want to take always first 2 words from 'my-thought-of-the-day-problem-of-traditional-educatio‌​n' then we can make '/1-my-thought', but if you will have different strings like 'my-stuff-education-is-cool', then we will not be able to apply a pattern using regular expressions. Please, provide more original links (3+) you would like to change, so I can see if there is any pattern.

If there is no pattern at all it is possible to use, for example, RewriteMap for Apache with an additional script on the server side, which will handle your links, but it's a more complex way, so let's stick to regular rewrites for now. Waiting for 3+ more examples.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top