Community @ The Turning Gate

Support community for TTG plugins and products.

You are not logged in.

#1 2018-12-03 02:21:32

markharris
Member
From: Uppsala, Sweden
Registered: 2013-01-21
Posts: 48
Website

Explanation of .htaccess file ?

Would it be possible to get an explanation of the contents of the .htaccess file ?
I have successfully converted my CE4 pages to BL2, but I have an awful lot of older hand-coded pages that are upset by the appearance of the new rewrite rules.

I understand that they are needed when using the Pages module, and saw a comment "that they are probably there for a reason",
which I'm sure is true, but I would like to understand why they are there in case there are some lines that in my case could be commented out.

For example, I have dozens of old pages that refer to image files that live at the top level (bad organisation, but stuck with it after 20 years of development), and all those links get broken unless I comment out the PNG and JPG rewrites.
My BL2 Pages appear to still work without those lines, even when they contain embedded jpegs, but I would like to know if I'm setting myself up for problems later.

I'm sure I'm not alone in having a big old site with a mixture of BL and legacy pages that would take weeks to reorganise, and there are probably other people who are adding hand-coding to BL pages who would benefit from an understanding the .htacces file.

Offline

#2 2018-12-03 02:58:02

Matthew
Administrator
From: Seoul, South Korea
Registered: 2012-09-24
Posts: 5,453
Website

Re: Explanation of .htaccess file ?

Hi Mark,

I believe Ben posted an unannounced update recently that allows assets to live in the "home" location. Though it's not our suggested way of doing things -- we advise putting assets into the backlight/custom folder, for example -- we understand that some users, such as yourself, may have reasons for having assets at root.

The .htaccess is something that Backlight's updater can update, so you'll need to download the ZIP file again using the link emailed to you at time of purchase, then manually copy the updated file to your site.


Campagna Pictures, http://campagnapictures.com
The Turning Gate, http://theturninggate.net

Offline

#3 2018-12-03 05:23:15

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 15,205
Website

Re: Explanation of .htaccess file ?

If you’re curious, a good starting point is a CE4 document that Matt created.
And while it doesn’t have anything to directly do with Backlight, it gives you an idea of what can be done
http://ce4.theturninggate.net/docs/doku … s_creation


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Pangolin test site, Backlight 1.1.1 test site

Offline

#4 2018-12-03 17:03:45

markharris
Member
From: Uppsala, Sweden
Registered: 2013-01-21
Posts: 48
Website

Re: Explanation of .htaccess file ?

Thanks for the quick reply, but the .htaccess in the Backlight-2-Installer-105 that I just downloaded seems to have the same .htaccess, and its date is 2018-10-09 as with the other files.

Offline

#5 2018-12-03 19:22:34

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 3,773

Re: Explanation of .htaccess file ?

We have not yet updated the .htaccess file.  It's in our working code and will come along with the next maintenance release.

The only functional change is that it will fix the issue that you've found - that of inadvertently failing to allow real resource files at the top level.
Those lines are currently redundant, so commenting them out as you have done will be fine.

For a technical explanation, there are checks in the .htaccess that will allow real files to be loaded if they exist.  Unfortunately, those checks only apply until the next rule that has an L between the square brackets.  So it's a logic error in our .htaccess file that prevents those resource files from being loaded if they're actual files on disk.

Offline

#6 2018-12-03 19:24:52

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 3,773

Re: Explanation of .htaccess file ?

For your info, here's the new version of the .htaccess file.  We haven't fully tested it but it should work properly:

<IfModule mod_headers.c>
    <FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
        Header set Access-Control-Allow-Origin "*"
    </FilesMatch>
</IfModule>

<IfModule mod_rewrite.c>
	RewriteEngine On

	# The below two lines will take a REQUEST_URI like /directory/foobar.php and set the variable BASE to /directory/
	#RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
	#RewriteRule ^(.*)$ - [E=BASE:%1]

	RewriteBase /
	RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
	RewriteRule ^.*$ - [E=BASE:%2]

	RewriteRule ^(.*)$ - [E=QS:mod_rewrite=on]

	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^([^\/.]*)-single.php$ %{ENV:BASE}single.php?%{ENV:QS}&id=$1 [QSA,L]

	# Attempt to load dynamic resources if file doesn't exist
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^([^\/.]*)\.(css|js|gif|png|jpg)$ %{ENV:BASE}index.php?%{ENV:QS}&extension=$2&name=$1 [QSA,L]

	#RewriteCond %{QUERY_STRING} !mod_rewrite=on
	#RewriteRule ^index.php$ %{ENV:BASE}index.php?%{ENV:QS} [QSA,L]

	RewriteCond %{QUERY_STRING} !mod_rewrite=on
	RewriteRule ^mobile.php$ %{ENV:BASE}mobile.php?%{ENV:QS} [QSA,L]

	RewriteCond %{QUERY_STRING} !mod_rewrite=on
	RewriteRule ^(.*)download.php %{ENV:BASE}download.php?%{ENV:QS} [QSA,L]

	# Address is /
	RewriteRule ^$ %{ENV:BASE}index.php?%{ENV:QS} [QSA,L]

	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^(.*)$ %{ENV:BASE}index.php?%{ENV:QS}&page=$1 [QSA,L]

</IfModule>

Offline

#7 2018-12-04 12:17:40

Matthew
Administrator
From: Seoul, South Korea
Registered: 2012-09-24
Posts: 5,453
Website

Re: Explanation of .htaccess file ?

Sorry about the misinformation! We'd been talking about it recently, and I thought it had already been posted. A miscommunication on my part.


Campagna Pictures, http://campagnapictures.com
The Turning Gate, http://theturninggate.net

Offline

#8 2018-12-04 18:03:22

markharris
Member
From: Uppsala, Sweden
Registered: 2013-01-21
Posts: 48
Website

Re: Explanation of .htaccess file ?

Great. All my old pages work now, living happily alongside my BL site,
Thanks for the quick support.

Offline

#9 2018-12-04 18:15:17

BleekerVision
Member
From: Hoevelaken in the Netherlands
Registered: 2015-12-22
Posts: 18
Website

Re: Explanation of .htaccess file ?

I have one question about the .htaccess file. What do I add to this file to make sure https is being used?

Offline

#10 2018-12-04 18:50:25

Rainer Goergen
Member
From: Trier, Germany
Registered: 2016-05-01
Posts: 304
Website

Re: Explanation of .htaccess file ?

After RewriteEngine on:

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Rainer

Edit: And you need a ssl certificate of your profider and enable ssl.

Last edited by Rainer Goergen (2018-12-04 18:57:59)

Offline

#11 2018-12-04 21:28:25

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 15,205
Website

Re: Explanation of .htaccess file ?

And make sure that you change the Company and Site URLs in Settings.
See this thread for more: http://community.theturninggate.net/vie … 289#p47289


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Pangolin test site, Backlight 1.1.1 test site

Offline

Board footer

Powered by FluxBB