Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-11-03 01:30:29

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Upgraded from 4.5.7 to 4.8.3 and .htaccess custom rewrite goes 404

Not sure if this should be in Troubleshooting or How? section of the forum… here goes…

Prior to upgrading from TXP 4.5.7 with PHP 4.6.4 to TXP 4.8.3 with PHP 7.3.23), the custom URLs to display individual images with articles in my Projects section worked fine (did not 404 & showed images using a custom url rewrite in my .htaccess. I have edited my error_default page template to display the image and image info (adi_gps correctly retrieves the URL variables, image and img-alt, as the names are specified in my .htaccess file).

Here is an example Projects article.
Click on any of the thumbnail images to trigger the 404.
Or, just click here to go directly to one of the URLs that triggers the 404.

I have also noticed that a 404 happens if I remove the trailing slash from a link to a site section (for example Contact: https://www.staceyirvin.com/contact ). I don’t recall that happening before.

Here is my Diagnostics Info:

Textpattern version: 4.8.3 (596bca03a4b32004412499363cecec62)
Last update: 2020-10-18 19:18:49/2020-10-21 02:09:56
Site URL: www.staceyirvin.com
Admin URL: www.staceyirvin.com/textpattern
Document root: /home3/photonom/public_html/staceyirvin
$path_to_site: /home3/photonom/public_html/staceyirvin
Textpattern path: /home3/photonom/public_html/staceyirvin/textpattern
Article URL pattern: title_only
Production status: debug
Temporary directory path: /home2/photonom/public_html/staceyirvin2/textpattern/tmp
PHP version: 7.3.23
GD Graphics Library: bundled (2.1.0 compatible); Supported formats: GIF, JPEG, PNG, WebP.
Server timezone: America/Boise
Server local time: 2020-11-02 17:43:38
Daylight Saving Time enabled?: 0
Automatically adjust Daylight Saving Time setting?: 1
Time zone (GMT offset in seconds): America/Chicago (-21600)
MySQL: 5.7.23-23 (Percona Server (GPL), Release 23, Revision 500fcf5) 
Database server time: 2020-11-02 17:43:38
Database server time offset: 0 s
Database server timezone: SYSTEM
Database session timezone: SYSTEM
Locale: en_US.UTF-8
Site / Admin language: en-us / en-us
Web server: Apache
PHP server API: cgi-fcgi
RFC 2616 headers: 0
Server OS: Linux 4.14.146-225.ELK.el7.x86_64
Admin-side theme: hive 4.8.3
Active plugins: 
	adi_calc-1.2
	adi_cat_menu-0.7
	adi_gps-0.4
	adi_link-0.2
	adi_search_db-0.3
	aks_table-0.2
	com_connect-4.6.0
	etc_query-1.3.5
	glz_custom_fields-2.0 beta
	kuo_tinymce_cdn-0.2
	lam_addthis-0.4
	lam_dynamic_image-0.1
	mta_sanitize-0.1
	pm_if_no_articles-0.2
	rah_external_output-1.0.4
	rah_function-0.7.1
	rah_repeat-1.0.1
	rss_auto_excerpt-0.5
	rss_suparchive-0.18
	rvm_if_this_article-0.1
	sho_urlencode-0.3
	smd_each-0.2
	smd_if-1.0.0
	smd_lib-0.36
	smd_parent-0.1
	smd_query-0.50
	smd_thumbnail-0.6.0
	smd_where_used-0.2
	smd_wrap-0.3.0
	smd_xml-0.3
	soo_page_numbers-0.4.2
	soo_plugin_pref-0.2.3
	upm_insert_tab-0.3
	upm_textile-0.3
	wet_for_each_image-0.5

.htaccess file contents: 
------------------------
# BEGIN Textpattern

#DirectoryIndex index.php index.html

<IfModule mod_rewrite.c>
    RewriteEngine On

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

    RewriteCond %{HTTP_HOST} !^www.staceyirvin.com$ [NC]
    RewriteRule ^(.*)$ https://www.staceyirvin.com/$1 [L,R=301]
    RewriteRule ^([^/]+)/image/(\d+)/(.+)$ /$1?image=$2&img-alt=$3

    # Enable the `FollowSymLinks` option below if it isn't already.
    #Options +FollowSymlinks

    #RewriteBase /relative/web/path/

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]

    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^(.*) index.php

    RewriteCond %{HTTP:Authorization}  !^$
    RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

<IfModule mod_mime.c>
    AddType image/svg+xml  svg svgz
    AddEncoding gzip       svgz
</IfModule>

# For additional Apache-compatible web server configuration settings to enhance
# site performance and security, we recommend:
# https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess

# END Textpattern

------------------------

Last edited by photonomad (2020-11-03 01:31:29)

Offline

#2 2020-11-03 11:56:26

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Upgraded from 4.5.7 to 4.8.3 and .htaccess custom rewrite goes 404

What happens if you delete

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

    RewriteCond %{HTTP_HOST} !^www.staceyirvin.com$ [NC]
    RewriteRule ^(.*)$ https://www.staceyirvin.com/$1 [L,R=301]
    RewriteRule ^([^/]+)/image/(\d+)/(.+)$ /$1?image=$2&img-alt=$3

from your htaccess?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2020-11-03 12:07:36

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Upgraded from 4.5.7 to 4.8.3 and .htaccess custom rewrite goes 404

photonomad wrote #326659:

I have also noticed that a 404 happens if I remove the trailing slash from a link to a site section (for example Contact: https://www.staceyirvin.com/contact ). I don’t recall that happening before.

The problem probably comes from here. Your permlink mode is title_only, so txp considers https://www.staceyirvin.com/contact URL as link to contact article, not section. Same for redirected links: www.staceyirvin.com/guatemala?image=245&img-alt=la-familia works (up to a bunch of tag errors), but www.staceyirvin.com/guatemala/?image=245&img-alt=la-familia does not, since you must have guatemala article, but not guatemala section. It probably worked before, but URL resolution has slightly changed to allow for mode-agnostic section/title links. Sorry for the trouble it might have caused.

Try rewriting links more consistently: with a trailing slash for article lists (sections etc) and without it for individual articles.

Offline

Board footer

Powered by FluxBB