Htaccess redirect URL to another URL
First of all you can create an .htaccess file on your web server. you can create file using FTP and SSH. Here you can use FTP because it is easy as compare to command line. These are the other FTP clients you can use for htaccess redirect URL to another URL:
- File zilla
Here you can use file zilla for htaccess redirect URL to another URL. Using file zilla you can see that how to create or delete a file and edit it. you should download file zilla. Here is the link of file zilla. (https://filezilla-project.org/download.php?platform=win64).using this link you can download file zilla.
How to create file?
- Login to server using FTP
- Ensure that FTP client show hidden files
- When you are login you must ensure that you are in correct directory or not. you can see that in image you are in remote title. And directory address is /home/example_username/arzhost.com.
- Right click and create new file.
5. you can see a prompt here you enter the file name .htaccess. Click on ok and save it.
6.you can see that an .htaccess file which is empty.
How to edit file?
How to edit and delete file follow these steps:
7. Move the cursor on .htaccess file right click on file and click on view or edit.
8. In prompt you can see that he asking that which editor you want to choose. you can choose your own editor which is install in our system. But here you choose default editor notepad, because it is easy to use.
9. Now open the file and add any txt on notepad.
10. Click on file and save it.
11. Within few seconds you see prompt check the box and click on yes
Now .htaccess file is update on web server.
How to delete file?
12. When you are login your web server ensure that you are in correct directory or not.
13. Right click on the file and choose
14. On prompt you can see that he asking him that you want to delete this file or not we click on YES.
how htaccess redirect url to another url?
Redirect all URLS
If you want to redirect all URLS on your new site then you write this line.
Redirect 301 / https://arzhost.com
Redirect a single URL
If want to redirect a single url then follow these steps.
For redirect to local site file:
Redirecting to an external site file:
Here are few examples of redirects
Redirect directory to HTML file
These lines will redirect the directories to an HTML file
Redirecting index.html files to different directories
These lines redirect html index files to different directory.
How to load a .gif file from a different site
These lines load a gif files from different sites
Redirect error massage
you can redirect error massage 404.rather than by send a 404 page. These lines will redirect to homepage.
Redirecting non-existing page to index.php
If a user open page which is not exist then 404 error will present. you can redirect non-existing page to index.php by sing these lines.
Enforcing www in URL
If you want to write www in your URL address then you follow these lines of code.
Remove www in URL
If you want to remove www in our URL then there is a minor change in code. which you use to enforce www in URL .
10. Rewriting non-existing links index.php
These lines are link to non-existing folder or files. If files or folder exist then it load automatic.