D
D
demidov_grinch2017-02-07 12:01:19
htaccess
demidov_grinch, 2017-02-07 12:01:19

How to redirect from one page to another using .htaccess?

Hello dear gentlemen!
How to make it so that if a person visits a link like: www.mysite.ru/test.aspx the .htaccess file would redirect him to the same html page ( www.mysite.ru/test.html)
There is a .htaccess code:

RewriteCond %{REQUEST_URI} ^/test.aspx$
RewriteRule ^.*$ http://mysite.ru/test.html? [R=301,L]

I don't understand what's wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2017-02-07
@demidov_grinch

RewriteCond %{REQUEST_URI} ^(.*)\.aspx$
RewriteRule ^.*$ http://mysite.ru/%1.html? [R=301,L]

If group is in RewriteRule then each parenthesis is $1$2 and so on
If parenthesis is in RewriteCond then %1 %2

D
demidov_grinch, 2017-02-09
@demidov_grinch

Found another way:
Redirect 301 /test.aspx http://mysite.ru/test/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question