We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    Hi,

    I need to transform http://mysite.com/staging into http://mysite.com/ and
    http://mysite.com/staging/whatever.html into http://mysite.com/whatever.html

    My htaccess file looks like this:

    # For full documentation and other suggested options, please see
    # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
    # including for unexpected logouts in multi-server/cloud environments
    # and especially for the first three commented out rules
    
    #php_flag register_globals Off
    #AddDefaultCharset utf-8
    #php_value date.timezone Europe/Moscow
    
    Options +FollowSymlinks
    RewriteEngine On
    
    RewriteBase /staging/
    
    # Fix Apache internal dummy connections from breaking [(site_url)] cache
    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
    RewriteRule .* - [F,L]
    
    # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
    #RewriteCond %{HTTP_HOST} .
    #RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
    #RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    
    # Exclude /assets and /manager directories and images from rewrite rules
    RewriteRule ^(manager|assets)/*$ - [L]
    RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
    
    # For Friendly URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    
    # Reduce server overhead by enabling output compression if supported.
    #php_flag zlib.output_compression On
    #php_value zlib.output_compression_level 5



    I personally tried a few solutions but not being a htaccess guru it didn’t work

    Thank you
      • 26016
      • 561 Posts
      Hi,
      I just did one of these live today. I will assume that you moved or copied your files to the root. smiley On the hosts I use, generally all I have to change is this in htaccess...

      RewriteBase /staging/

      ... to this...

      RewriteBase /

      ...If I’m moving to the root.

      And don’t forget that you have 2 spots in your config to change:

      Tools, Configuration, File Manager, File Manager Path.
      ... and...
      Tools, Configuration, Interface/Features, File Base Path.

      Beyond that I don’t have to change anything else! The only other thing that occasionally comes up is if I have a hard-coded Base Href in my templates instead of the handy modx template variable of [(site_url)]

      YMMV.
      Hope that helps, Dave
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 5340
        • 1,624 Posts
        Thanks Samba but I am trying to do it without moving the files.

        Something in the htaccess that will remove the staging part by rewriting the url
          • 26016
          • 561 Posts
          Right. That’s a horse of a different color. I am decent with .htaccess, but not overly fluent, so I very quickly get in over my head. smiley

          I have something to look at. Take a peek here, and I wonder if the "multiple domains in one root" section may provide a code example to get you started.
          http://corz.org/serv/tricks/htaccess2.php

          Cheers, Dave

            MODx and Wordpress development
            Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
            • 5340
            • 1,624 Posts
            I tried a few of those solutions without success. I think they interfere with the parts of the default modx htaccess file.

            Unfortunately I don’t have time to pursuit this and I just moved the files.