I have a website in which there are two html pages and .htaccess

volk ​​@ Sivadra: ~ $ ls -a ~ / web / test.dev /. .. .directory .htaccess page1.html page2.html

.htaccess look like this

volk ​​@ Sivadra: ~ $ cat ~ / web / test.dev / .htaccess RewriteEngine On RewriteRule page1.html page2.html

But when I go to test.dev/page1.html the redirect does not occur . The command showing apache modules shows that the rewrite module is

volk ​​@ Sivadra: ~ $ apachectl -t -D DUMP_MODULES | grep -i "rewrite" rewrite_module (shared)

Even if you browse the directory with modules, the published link is shown

volk ​​@ Sivadra: ~ $ ls -Fal / etc / apache2 / mods-enabled / | grep -i "rewrite" lrwxrwxrwx 1 root root July 30 30 14:06 rewrite.load -> ../mods-available/rewrite.load

The content of the file referenced by this link

volk ​​@ Sivadra: ~ $ cat /etc/apache2/mods-available/rewrite.load LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

Even just in case I checked if this module exists

volk ​​@ Sivadra: ~ $ file /usr/lib/apache2/modules/mod_rewrite.so /usr/lib/apache2/modules/mod_rewrite.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID [sha1] = 69db4255e339924d7facba51f8429824109cd398, stripped

The virtual host file looks like this:

<VirtualHost *:80> ServerName test.dev ServerAlias www.test.dev DocumentRoot /home/volk/web/test.dev ServerAdmin webmaster@localhost <Directory "/home/volk/web/test.dev"> Require all granted Options +Indexes </Directory> </VirtualHost> 

Why not redirect?

    1 answer 1

    1. Because you did not specify RewriteCond

    2. Because rewrite is not a redirect.

    Redirect this here - Redirect 301 page1.html page2.html

    • But could you tell me how in this case it should look like .htaccess, otherwise it’s impossible for me to compose it myself. - Faydaen
    • Read above Redirect 301 page1.html page2.html that's all - Snow