Dino Geek, try to help you

How to redirect a URL in Apache?


You can redirect a URL in Apache using the redirection techniques in the .htaccess file or inside the apache site configuration file depending on the scope you want to apply it to. Here are the steps:

1. Open the Apache configuration file. The location of this file could be – `/etc/apache2/httpd.conf` or `/etc/httpd/httpd.conf`, and in some cases `/etc/apache2/apache2.conf`.

1. Search for the line that starts with `

1. If you want to apply the redirect to the whole website, add these lines:
```
RewriteEngine On
RewriteRule ^(.*)$ http://www.new-website.com/$1 [R=301,L]
```
This redirects all paths in your old domain to the respective path on the new domain.

1. If you want to apply a redirect to a specific page only, replace the general rule `^(.)$` with the part of the URL that comes after your site domain. For example, if the page was `http://www.oldwebsite.com/books`, you would replace `^(.)$` with `^books$`:
```
RewriteEngine On
RewriteRule ^books$ http://www.new-website.com/new-books [R=301,L]
```

1. Save the changes to the file and exit the editor.

1. Test the configuration: `sudo apachectl -t`,

1. If the test is successful, reload the Apache configuration: `sudo system apache2 reload` or `sudo systemctl restart httpd` or `sudo service apache2 reload`

Please note that Apache `mod_rewrite` module needs to be enabled for redirection to work. You can enable it using the command `sudo a2enmod rewrite` and then restart the Apache service.

Also, please make a backup of any files before making any changes.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use