A few days ago I told you about .htaccess, I made an introduction and everything 🙂
Well, as I said at the end of that post ... now it's time to talk about redirect with htaccess. That is, when they access / enter a URL or folder using a browser, another URL is automatically changed / redirected / opened.
I mean ... to explain even simpler 😀
We enter for example: http://sitio.com/carpetas/ and we see that there are 2 folders, / folder1 / y / folder2 /
If we enter / folder1 / we see the normal content, but if we enter / folder2 / then automatically our browser will go to another site, the one we want ... regardless of whether we want to or not.
This is what I'm talking about.
A typical example is one that we have done here in DesdeLinux 😀
If you enter: http://www.desdelinux.net … You will see how they are automatically redirected to the blog (https://blog.desdelinux.net)
For me to achieve this, I just had to put in the .htaccess following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* https://blog.desdelinux.net/
</IfModule>
Is it understood not?
These lines explained in a simple way would be:
- Start using Apache's rewrite module.
- If the rewrite engine is started ...
- I set the rule: open https://blog.desdelinux.net
- I close the use of the module.
If you want another link to be accessed, you just have to change the path (in the example it is the blog address) and voila 😀
I hope it is useful to you.
The next thing I'll put on .htaccess I think it will be redirect too, but with conditions. That is, if you are entering from http://link1.sitio.com then I redirect you to http://sitio.com ... but if you are accessing through http://link2.sitio.com then i'll redirect you to http://pepito.net
And some more tips 😀
However, if anyone has a question with .htaccess or need something, he tells me that I will help him as much as I can.
regards
Posts related to topics like these are always the best, always very useful information 😀
Cheers(:
Thanks for the comment 🙂
Good info KZKG ^ Gaara.
Thank you
Very good tip ……
Thanks partner 😀
Luxury and of interest, especially for webmasters.
Thank you!
Thanks to you for the comment 😀