Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. LAMP
  3. LMAP .htaccess rewrite rules with google analytics - Help needed

LMAP .htaccess rewrite rules with google analytics - Help needed

Scheduled Pinned Locked Moved Solved LAMP
21 Posts 3 Posters 1.6k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    privsec
    wrote on last edited by
    #12

    Ahh, I see. I am using the .php file as that was what was recommended above.

    If I could do it all in one place than that is preferred.

    If I do it in the .php file, is the redirect immediate?
    I do not want the end user to sit and wait or anything

    1 Reply Last reply
    0
    • robiR Offline
      robiR Offline
      robi
      wrote on last edited by
      #13

      It's as immediate as you make it, with messages, delays or not.

      Conscious tech

      1 Reply Last reply
      1
      • P Offline
        P Offline
        privsec
        wrote on last edited by
        #14

        Everything I'm finding online keeps referring to use .htaccess to do the redirect.

        So can you point me in the right direction?

        1 Reply Last reply
        0
        • P Offline
          P Offline
          privsec
          wrote on last edited by
          #15

          Actually, I just found

          <!DOCTYPE HTML>
          <html lang="en-US">
              <head>
                  <meta charset="UTF-8">
                  <meta http-equiv="refresh" content="0; url=http://example.com">
                  <script type="text/javascript">
                      window.location.href = "http://example.com"
                  </script>
                  <title>Page Redirection</title>
              </head>
              <body>
                  <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
                  If you are not redirected automatically, follow this <a href='http://example.com'>link to example</a>.
              </body>
          </html>
          

          And I found

          <!DOCTYPE HTML>
           
          <meta charset="UTF-8">
          <meta http-equiv="refresh" content="1; url=http://example.com">
           
          <script>
            window.location.href = "http://example.com"
          </script>
           
          <title>Page Redirection</title>
           
          <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
          If you are not redirected automatically, follow the <a href='http://example.com'>link to example</a>
          
          1 Reply Last reply
          0
          • P Offline
            P Offline
            privsec
            wrote on last edited by
            #16

            So I still don't know what is wrong. It should be working.

            image.png

            This is now what I have in index.php

            
            <!DOCTYPE HTML>
            <html lang="en-US">
                <head>
                    <meta charset="UTF-8"><meta http-equiv="refresh" content="0; url=https://discord.gg/bG$$$$$$$">
                    <script type="text/javascript">
                        window.location.href = "https://discord.gg/bGH$$$$$$$"
                    </script>
                    <title>Community</title>
                </head>
                <script async src="https://www.googletagmanager.com/gtag/js?id=G-H65$$$$$$$"></script>
            <script>
              window.dataLayer = window.dataLayer || [];
              function gtag(){dataLayer.push(arguments);}
              gtag('js', new Date());
            
              gtag('config', 'G-H65$$$$$$$');
            </script>
                <body>
                    <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
                    If you are not redirected automatically, follow this <a href='https://discord.gg/bG$$$$$$$'>link to our community</a>.
                </body>
            </html>
            
            

            This is my .htaccess file

            # Permanent URL redirect 
            # RewriteEngine on
            # Redirect 302 / https://discord.gg/b34345345345
            
            1 Reply Last reply
            0
            • P Offline
              P Offline
              privsec
              wrote on last edited by
              #17

              The redirect is working as I would expect it to, but GA isn't working

              1 Reply Last reply
              0
              • robiR Offline
                robiR Offline
                robi
                wrote on last edited by
                #18

                That does not look like a php file. Perhaps rename it to .html

                Conscious tech

                1 Reply Last reply
                1
                • P Offline
                  P Offline
                  privsec
                  wrote on last edited by
                  #19

                  Renamed from index.php to index.html

                  redirect works, GA doesn't

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    privsec
                    wrote on last edited by
                    #20

                    I noticed my GA was outside my head tag (DOH!) but even after moving that, it still isn't being recognized.

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      privsec
                      wrote on last edited by
                      #21

                      AAannnnnd now it is working. I wish I could tell you why, but I don't.

                      Thanks @robi

                      1 Reply Last reply
                      1
                      • J joseph marked this topic as a question on
                      • J joseph has marked this topic as solved on
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Bookmarks
                      • Search