htaccess [Redirect]: Rules, regulations, control over your content published on the network

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:

  1. Start using Apache's rewrite module.
  2. If the rewrite engine is started ...
  3. I set the rule: open https://blog.desdelinux.net
  4. 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


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Diego Campos said

    Posts related to topics like these are always the best, always very useful information 😀

    Cheers(:

    1.    KZKG ^ Gaara said

      Thanks for the comment 🙂

  2.   proper said

    Good info KZKG ^ Gaara.

    1.    KZKG ^ Gaara said

      Thank you

  3.   elMor3no said

    Very good tip ……

    1.    KZKG ^ Gaara said

      Thanks partner 😀

  4.   elynx said

    Luxury and of interest, especially for webmasters.

    Thank you!

    1.    KZKG ^ Gaara said

      Thanks to you for the comment 😀