Hi all
Newbie to Modx here !
Have installed modx and susequently looked at the file/folder additions to the file manager.
Also read about friendly URLs etc and how one might need to edit the code in .htaccess.
Now I notice I have an .htaccess file in my root folder which contains script relevant to modx.
I see I also have another .htaccess file in my public_html folder (where my add-on domain is located that holds the modx files)
but this .htaccess file is completely empty of any script.
I also notice there is a ht.access file in the modx folders that contains the exact same script as the .htaccess in my root.
I read that upon editing the ht.access for friendly urls, it must be re-named to .htaccess and saved.
My questions are :
What purpose does the empty .htaccess file serve in the public-html folder?
(Is that just for non-modx related configurations, hence I can ignore for now?)
Do I have to convert the ht.access to .htaccess for modx to work whether or not I want friendly urls?
I believe editing the converted ht.access file doesn’t automatically mirror the same edits into the .htaccess in the root, so
do i have to make the same changes to both so they always contain the exact same script?
Can I remove one and just leave the other ...if so which ?
Many thanks for any ’much needed’ clarification.
Steveed
Steveed[br /]
New to Modx
Working with Rev 2.0.7-pl
Welcome Steve,
You’re on the right track. On many hosts, I’ve seen the odd empty .htaccess file, and it often cannot be deleted! But because it’s empty, it’s harmless, and can be ignored. And to put it another way, these empty ones are coming from your server, not MODx.
So yes, the ht.access is the example file, you can edit that for FURL’s and then rename it to .htaccess, replacing the empty one. 95% of the time the only edit I do in my FURL’s .htaccess is the Rewrite base line.
And yes, when you move MODx into the root of your site, you will need to replace that .htacess with your new edited one, it doesn’t happen automagically.
Cheers, Dave
Hi Dave
Many thanks for the reply.
I’m still not quite there with it....
Do I need to convert the ht.access to .htaccess for modx to function properly? (even if I didnt want friendly urls)
I was hoping to leave the modx installation in my add-on domain and not move it to the root folder ...is that a problem?
Therefore I’ll end up with two htaccess files (i.e. in the root and in the add-on domain modx folder. Do I need to eliminate one ?
Sorry for playing this out I just need to fully understand .
Many thanks
Steveed
Steveed[br /]
New to Modx
Working with Rev 2.0.7-pl
Steve,
No problem. I’ve been at this a LONG time, and I’m still not an expert .htaccess programmer - whenever I make or alter one, I have to refer to examples. I know enough to get my job done, and that’s about it. Not my cup of tea, programming in mod_rewrite. Programming REGEX commands is another one like that.... I can do it, but it’s not overly fun.
No, if you’re going to avoid FURL’s, you may have no need to use an .htaccess file at all! I know I don’t have to, on the fairly normal hosts I work with.
I think I’m getting the picture on your set-up... I have loads of sites like that myself, with add-on domains in subfolders of my root. So no, no need to necessarily move your site to the root in that scenario - if your new domain is working in the subfolder, as they say, it ain’t broke, and no need to fix it!
In fact, I have SO many sites that work that way, once in a great while I’ve run into situations where my root .htaccess might make a problem with a site in a subfolder. To fix that, I’ve written code in the root .htacess to exclude that subfolder from the .htaccess commands I’m using, and then it’s fine again. You may not need to do this at all.
If you have a CPanel-style reseller account, you may have access to WHM, which allows you to create sites that are entirely separate from your main site’s filesystem - and then there can be no conflict with your root’s .htaccess.
Cheers, D
Hi Dave
Thanks again for getting back.
I still haven’t nailed it, so given that I’ll leave modx on a suddomain...
I can ignore the empty .htacces in my PUBLIC_HTML folder ...OK CLEAR !
I don’t need to re-write code if not using friendly URLs....OK CLEAR !
DO I STILL NEED TO RE-SAVE THE ht.access to .htaccess anway...is this a must for modx to work ?
IF I DO SAVE IT AS .htaccess WHAT DO I DO WITH THE .htaccess IN MY ROOT FOLDER ?
I will now have 2 exact same .htacces files with the same script.
CAN I ELIMINATE ONE...IF SO WHERE SHOULD THE REMAINING ONE LIVE ... IN THE MODX FOLDERS...HAVING 2 DOESNT SEEM LOGICAL TO ME?
Many thanks
Steve
Steveed[br /]
New to Modx
Working with Rev 2.0.7-pl
-
☆ A M B ☆
- 24,524 Posts
.htaccess are inherited; each folder will inherit the directives from its parent. Any .htaccess directives in a child folder will override the same directive in a parent folder.
Whether or not you need an .htaccess at all anywhere on your site if you don’t want to use the rewrite rules to enable friendly URLs depends entirely on your server’s configuration. The server may require some settings; for example my Bluehost requires a line to indicate that I’m using PHP as a CGI and not an Apache module.
# Use PHP5CGI as default
AddHandler fcgid-script .php
If your server’s file structure uses symlinks (www => public_html) you may need to have a line enabling FollowSymlinks, it that’s not already enabled in the httpd.conf configuration file for Apache.
So it’s kind of hard to say that you don’t need an .htaccess file at all; MODx certainly doesn’t need one unless you want to enable friendly URLs.
hi Susan
Thanks for that.
I also host at Bluehost.com... just started.
Thanks for the code snippets which look like they may come in useful.
I have decided to keep the empty .htaccess in the public_html folder in case I need to control something more general in the root.
I guess I’ll also convert the ht.access in the modx folder to .htaccess AND KEEP IT in case I DO decide to use friendly urls, or need your ’PHP as a CGI’ snippet.
One final question ...AM I SAFE TO DELETE THE .htaccess in the root folder which is a copy of the .htaccess in the modx folder?
Since as you say the child (.htaccess in modx) over-rides the parent (.htacces in root) what’s the point of the one in the root?
Hope I undesrtood right.
Steve
Steveed[br /]
New to Modx
Working with Rev 2.0.7-pl
-
☆ A M B ☆
- 24,524 Posts
With .htaccess it’s always safer to just rename it; that way if you start getting 500 errors on your site you can always change it back.
Steveed[br /]
New to Modx
Working with Rev 2.0.7-pl