On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • running:

    I followed the directions at http://wiki.modxcms.com/index.php/Friendly_URLs_Guide#Friendly_urls_without_mod_rewrite

    use friendly URLs: Yes
    Prefix for friendly URLs: /index.php?page=
    Suffix for friendly URLs: .html
    Use friendly aliases: Yes
    everything else: No

    I then went to an existing page (id=25) and gave it an Alias (test)

    When I opened a new browser and went to myurl.com?page=test it did not get the page
    however, when I tried myurl.com?id=25 the page come up.

    BTW... i also tried it using the mod_rewrite...but had no luck... I eventually gave up on the mod_rewrite (and renamed the files back to ht.access) and redid the tools/config/friendly urls to the above mentioned configuration (put back the prefix) and still no luck.

    Any ideas?

    I am running on a LAMP stack (Centos). Otherwise everything is working find with modx
    • DudeDad,

      there’s a whole thread on this here


      It’s about 14 pages long and growing, so there should be something in there to help.
        Content Creator and Copywriter
      • The technique you are using is for special cases where mod_rewrite is not available, which we do not recommend. If you have mod_rewrite, you should use friendly urls without that crazy prefix.
        • OpenGeek/markG:

          Thanks for your responses and the pointer to the 14 page thread on this topic.

          Nice to know that "it just ain’t me". Seems like it is more normal to have problems than to not have problems with this feature smiley . You’d think with this being a "SEO CMS" that this would be nailed by now.

          In any event, I could not see anything obvious in any of the postings that stands out. Markg’s thread is very similar to my story. I have my configurations set just has Mark’s and am getting <mostly> the same results.

          Below, I doublecheck and document the current settings. But first, I reiterate the behavior:

          The main behavior I am getting is:
          I set up a page and give it an alias (lets say "Test")
          When I save it It is given an ID of (say "37")
          When I preview it (from manager, of course) I see the unfrienldy URL of mysite.com?id=37. This is probably just due to the fact that the /manager directory has an .htaccess with rewrite disabled per the default install.

          However, when I go to a different browser (I fire up IE) and I type in fresh mysite.com/Test or mysite.com/Test.html I get 404’d

          However, if I go mysite.com?id=37 I get the page.

          The settings:

          When I read the thread that MarkG provided (I started at post 150 http://modxcms.com/forums/index.php/topic,4700.150.html so as to be dealing with 9.6.1 ) I could not see any silver bullets.

          The only things that sort of jingled a bell are:

          1) Did I install it in my root directory? I think I did. I am using CENTOS so the root is:
          /var/www/html . Thats where I installed it! I just double checked. Yup. that is the folder that has .htaccess (with type showing HTACCESS FILE) index.php and index-ajax.php as well as the folders Manager and Assets.

          Please confirm that I am current in that I do not have to touch the default line in .htaccess that says : "RewriteBase /"

          2) contents of the .htaccess file. I used the default file that came with the install. The only changes I did along the way was to add NC and to uncomment the FollowSymlinks line.
          Just now, I have deleted all the other (commented out) junk and deleted all extra empty lines etc. The entire file now is:
          Options +FollowSymlinks
          RewriteEngine On
          RewriteBase /
          # The Friendly URLs part
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]

          3) Double check the site settings:
          FURL Tab:
          Use friendly URLs: Yes
          Prefix for friendly URLs: ! I have this absolutely blank. I did not have "" or any other char
          Suffix for friendly URLs: .html
          Use friendly aliases: Yes
          Use friendly alias path: No
          Allow duplicate aliases: No
          Automatically generate alias: No

          3) Double check info.php to make sure that mod_rewrite is loaded: Looks good:

          Loaded Modules core prefork http_core mod_so mod_auth_basic mod_auth_digest mod_authn_file mod_authn_alias mod_authn_anon mod_authn_dbm mod_authn_default mod_authz_host mod_authz_user mod_authz_owner mod_authz_groupfile mod_authz_dbm mod_authz_default util_ldap mod_authnz_ldap mod_include mod_log_config mod_logio mod_env mod_ext_filter mod_mime_magic mod_expires mod_deflate mod_headers mod_usertrack mod_setenvif mod_mime mod_dav mod_status mod_autoindex mod_info mod_dav_fs mod_vhost_alias mod_negotiation mod_dir mod_actions mod_speling mod_userdir mod_alias mod_rewrite mod_proxy mod_proxy_balancer mod_proxy_ftp mod_proxy_http mod_proxy_connect mod_cache mod_suexec mod_disk_cache mod_file_cache mod_mem_cache mod_cgi mod_version mod_perl mod_php5 mod_proxy_ajp mod_python mod_ssl

          4) check HTTPd.CONF AllowOverride All : I enabled it everywhere I could find that string:

          # DocumentRoot: The directory out of which you will serve your
          # documents. By default, all requests are taken from this directory, but
          # symbolic links and aliases may be used to point to other locations.
          DocumentRoot "/var/www/html"
          # Each directory to which Apache has access can be configured with respect
          # to which services and features are allowed and/or disabled in that
          # directory (and its subdirectories). 
          # First, we configure the "default" to be a very restrictive set of 
          # features.  
          <Directory />
              Options FollowSymLinks
              AllowOverride All
          # Note that from this point forward you must specifically allow
          # particular features to be enabled - so if something's not working as
          # you might expect, make sure that you have specifically enabled it
          # below.
          # This should be changed to whatever you set DocumentRoot to.
          <Directory "/var/www/html">
          # Possible values for the Options directive are "None", "All",
          # or any combination of:
          #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
          # Note that "MultiViews" must be named *explicitly* --- "Options All"
          # doesn't give it to you.
          # The Options directive is both complicated and important.  Please see
          # http://httpd.apache.org/docs/2.2/mod/core.html#options
          # for more information.
              Options Indexes FollowSymLinks
          # AllowOverride controls what directives may be placed in .htaccess files.
          # It can be "All", "None", or any combination of the keywords:
          #   Options FileInfo AuthConfig Limit
              AllowOverride All
          # Controls who can get stuff from this server.
              Order allow,deny
              Allow from all
          # UserDir: The name of the directory that is appended onto a user's home
          # directory if a ~user request is received.
          # The path to the end user account 'public_html' directory must be
          # accessible to the webserver userid.  This usually means that ~userid
          # must have permissions of 711, ~userid/public_html must have permissions
          # of 755, and documents contained therein must be world-readable.
          # Otherwise, the client will only receive a "403 Forbidden" message.
          # See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
          <IfModule mod_userdir.c>
              # UserDir is disabled by default since it can confirm the presence
              # of a username on the system (depending on home directory
              # permissions).
              UserDir disable
              # To enable requests to /~user/ to serve the user's public_html
              # directory, remove the "UserDir disable" line above, and uncomment
              # the following line instead:
              #UserDir public_html
          # Control access to UserDir directories.  The following is an example
          # for a site where these directories are restricted to read-only.
          #<Directory /home/*/public_html>
          #    AllowOverride FileInfo AuthConfig Limit
          #    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
          #    <Limit GET POST OPTIONS>
          #        Order allow,deny
          #        Allow from all
          #    </Limit>
          #    <LimitExcept GET POST OPTIONS>
          #        Order deny,allow
          #        Deny from all
          #    </LimitExcept>
          # DirectoryIndex: sets the file that Apache will serve if a directory
          # is requested.
          # The index.html.var file (a type-map) is used to deliver content-
          # negotiated documents.  The MultiViews Option can be used for the 
          # same purpose, but it is much slower.
          DirectoryIndex index.html index.html.var index.htm index.shtml index.cgi index.php index.php3 index.pl
          # AccessFileName: The name of the file to look for in each directory
          # for additional configuration directives.  See also the AllowOverride
          # directive.
          AccessFileName .htaccess
          # The following lines prevent .htaccess and .htpasswd files from being 
          # viewed by Web clients. 
          <Files ~ "^\.ht">
              Order allow,deny
              Deny from all
          # TypesConfig describes where the mime.types file (or equivalent) is
          # to be found.
          TypesConfig /etc/mime.types
          # DefaultType is the default MIME type the server will use for a document
          # if it cannot otherwise determine one, such as from filename extensions.
          # If your server contains mostly text or HTML documents, "text/plain" is
          # a good value.  If most of your content is binary, such as applications
          # or images, you may want to use "application/octet-stream" instead to
          # keep browsers from trying to display binary files as though they are
          # text.
          DefaultType text/plain
          # The mod_mime_magic module allows the server to use various hints from the
          # contents of the file itself to determine its type.  The MIMEMagicFile
          # directive tells the module where the hint definitions are located.
          <IfModule mod_mime_magic.c>
          #   MIMEMagicFile /usr/share/magic.mime
              MIMEMagicFile conf/magic
          # HostnameLookups: Log the names of clients or just their IP addresses
          # e.g., www.apache.org (on) or (off).
          # The default is off because it'd be overall better for the net if people
          # had to knowingly turn this feature on, since enabling it means that
          # each client request will result in AT LEAST one lookup request to the
          # nameserver.
          HostnameLookups Off
          # EnableMMAP: Control whether memory-mapping is used to deliver
          # files (assuming that the underlying OS supports it).
          # The default is on; turn this off if you serve from NFS-mounted 
          # filesystems.  On some systems, turning it off (regardless of
          # filesystem) can improve performance; for details, please see
          # http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap
          #EnableMMAP off
          # EnableSendfile: Control whether the sendfile kernel support is 
          # used to deliver files (assuming that the OS supports it). 
          # The default is on; turn this off if you serve from NFS-mounted 
          # filesystems.  Please see
          # http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile
          #EnableSendfile off
          # ErrorLog: The location of the error log file.
          # If you do not specify an ErrorLog directive within a <VirtualHost>
          # container, error messages relating to that virtual host will be
          # logged here.  If you *do* define an error logfile for a <VirtualHost>
          # container, that host's errors will be logged there and not here.
          ErrorLog logs/error_log
          # LogLevel: Control the number of messages logged to the error_log.
          # Possible values include: debug, info, notice, warn, error, crit,
          # alert, emerg.
          LogLevel warn
          # The following directives define some format nicknames for use with
          # a CustomLog directive (see below).
          LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
          LogFormat "%h %l %u %t \"%r\" %>s %b" common
          LogFormat "%{Referer}i -> %U" referer
          LogFormat "%{User-agent}i" agent
          # "combinedio" includes actual counts of actual bytes received (%I) and sent (%O); this
          # requires the mod_logio module to be loaded.
          #LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
          # The location and format of the access logfile (Common Logfile Format).
          # If you do not define any access logfiles within a <VirtualHost>
          # container, they will be logged here.  Contrariwise, if you *do*
          # define per-<VirtualHost> access logfiles, transactions will be
          # logged therein and *not* in this file.
          #CustomLog logs/access_log common
          # If you would like to have separate agent and referer logfiles, uncomment
          # the following directives.
          #CustomLog logs/referer_log referer
          #CustomLog logs/agent_log agent
          # For a single logfile with access, agent, and referer information
          # (Combined Logfile Format), use the following directive:
          CustomLog logs/access_log combined
          # Optionally add a line containing the server version and virtual host
          # name to server-generated pages (internal error documents, FTP directory
          # listings, mod_status and mod_info output etc., but not CGI generated
          # documents or custom error documents).
          # Set to "EMail" to also include a mailto: link to the ServerAdmin.
          # Set to one of:  On | Off | EMail
          ServerSignature On
          # Aliases: Add here as many aliases as you need (with no limit). The format is 
          # Alias fakename realname
          # Note that if you include a trailing / on fakename then the server will
          # require it to be present in the URL.  So "/icons" isn't aliased in this
          # example, only "/icons/".  If the fakename is slash-terminated, then the 
          # realname must also be slash terminated, and if the fakename omits the 
          # trailing slash, the realname must also omit it.
          # We include the /icons/ alias for FancyIndexed directory listings.  If you
          # do not use FancyIndexing, you may comment this out.
          Alias /icons/ "/var/www/icons/"
          <Directory "/var/www/icons">
              Options Indexes MultiViews
              AllowOverride All
              Order allow,deny
              Allow from all
          # WebDAV module configuration section.
          <IfModule mod_dav_fs.c>
              # Location of the WebDAV lock database.
              DAVLockDB /var/lib/dav/lockdb
          # ScriptAlias: This controls which directories contain server scripts.
          # ScriptAliases are essentially the same as Aliases, except that
          # documents in the realname directory are treated as applications and
          # run by the server when requested rather than as documents sent to the client.
          # The same rules about trailing "/" apply to ScriptAlias directives as to
          # Alias.
          ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
          # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
          # CGI directory exists, if you have that configured.
          <Directory "/var/www/cgi-bin">
              AllowOverride All
              Options None
              Order allow,deny
              Allow from all

          You can also see in the above code that access file is set properly:
          # AccessFileName: The name of the file to look for in each directory
          # for additional configuration directives.  See also the AllowOverride
          # directive.
          AccessFileName .htaccess

          5) Do I need to put <base href="[(site_url)]" /> in my template head ? In Markg’s reply #203 this is mentioned (although related to a slightly different issue). I looked in my template for the page I am trying to access through its FURL and there is no base HREF statement:

          Here is the begining of the template used on the page that I am trying to access via FURL
           <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
          <title>Untitled 1</title>
          <link href="assets/tinoStyles.css" rel="stylesheet" type="text/css" />
          <style type="text/css">

          6) I read something in the thread about maybe the problem is cache. But I can not figure out where to release Modx’s cache.

          7) The only other thing that is unusual is that I purposely set up my site to not have any "menu" on it. To access a page it one needs to put in the full URL.


          • Having not heard back from the Forum, and being stuck at a standstill, I decided to go back further in the page thread to see if I could pick anything up from posts on early revs of Modx.

            I came across two things that I tried :

            1) Added <base href="[(site_url)]"></base> to the top of all my templates
            Per OpenGeek post #145 http://modxcms.com/forums/index.php/topic,4700.msg100000.html#msg100000

            2) Added the following lines to my /var/www/html/manager/includes/config.inc.php (per post #148)http://modxcms.com/forums/index.php/topic,4700.msg100038.html#msg100038

            $base_url=’http://yourdomain.com/’; ( of course, used my actual info)
            $base_path=’/relative/path/to/www/’; (since this is Centos, I put /var/www/html)

            Still, when I go to mysite.com/Test or mysite.com/Test.html I get 404’d. I can get the page in question if I do mysite.com?id=37


            Any ideas?

            • ....and then I rebooted the LAMP server....

              All of a sudden it started working.... smiley good enough for me!
              • wink Yeah, the changes you made to httpd.conf regarding the AllowOverride All had to be loaded into Apache; thus the restart was required in order for your .htaccess RewriteRules to be recognized.

                Glad you got it figured out.