Page 1 of 1

Section header in URL - 404

Posted: Wed Aug 21, 2019 1:41 pm
by thecarp
Hi,

I'm doing multilanguage page using Section headers, but I have a problem loading page - 404 returned.

My pages structure:
- EN (Section header)
- - home (content)
- - ... (content)
- - contact (content)
- ES (Section header)
- - lorem ipsum (content)

URL example.com/es/lorem-ipsum/ returns 404.
URL example.com/lorem-ipsum/ works, but for me it's invalid URL format

.htaccess

Code: Select all

<IfModule rewrite_module>
	RewriteEngine on
	RewriteBase /

	RewriteCond %{REQUEST_URI} !\.[[:alnum:]]+$
	RewriteRule ^(.+[^/])$ /$1/ [R=302,L]

	RewriteCond %{HTTP_HOST} ^example.com$
	RewriteRule (.*) https://example.com/$1 [R=302,QSA,L]

	RewriteCond %{QUERY_STRING} http\: [OR]
	RewriteCond %{QUERY_STRING} \[ [OR]
	RewriteCond %{QUERY_STRING} \] [OR]
	RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
	RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
	RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
	RewriteRule ^.*$ - [F,L]

	# blog/ID/61/alias/ -> blog/ID-alias/
	RewriteRule blog\/(\d+)-(.*)\/ blog/$1/61/$2/

	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>

RedirectMatch 403 ^/.*\.htaccess$
RedirectMatch 403 ^/.*\.log$
RedirectMatch 403 ^/.*\.ini$
RedirectMatch 403 ^/.*config\.php$
RedirectMatch 403 ^.*/doc/.*$
RedirectMatch 403 ^.*/lib/.*\.php$
RedirectMatch 403 ^.*/tmp/.*\.php$
#RedirectMatch 403 ^.*/modules/.*\.php$
#RedirectMatch 403 ^.*/uploads/.*\.php$
RedirectMatch 403 ^.*/assets/.*\.php$
RedirectMatch 403 ^.*/assets/.*\.tpl$

<IfModule mod_headers.c>
    # Disable Last-Modified for performance
    Header unset Last-Modified
	# Disable ETags
	Header unset ETag
	FileEtag None
	# For Security
	Header set X-Frame-Options "SAMEORIGIN"
</IfModule>

<IfModule deflate_module>
	AddOutputFilterByType DEFLATE text/html text/css text/plain text/html text/xml image/gif image/jpeg image/png image/ico text/javascript application/x-javascript application/javascript application/json application/pdf
</IfModule>

<IfModule mod_expires.c>
	ExpiresActive On
	ExpiresDefault "access plus 1 month"
	# Set expires tags on various file types... so that the browser won't attempt to reload them.
	ExpiresByType image/jpg "access plus 1 year"
	ExpiresByType image/gif "access plus 1 year"
	ExpiresByType image/ico "access plus 1 year"
	ExpiresByType image/png "access plus 1 year"
	ExpiresByType video/x-flv "access plus 1 year"
	ExpiresByType application/pdf "access plus 1 year"
	ExpiresByType application/x-shockwave-flash "access plus 1 year"
	ExpiresByType application/javascript "access plus 1 month"
	ExpiresByType application/x-javascript "access plus 1 month"
	ExpiresByType text/javascript "access plus 1 month"
	ExpiresByType text/css "access plus 1 month"
	<IfModule mod_headers.c>
		# Setting cache control to public allows proxy servers to cache the items too.
		Header set Cache-Control "public"
	</IfModule>
</IfModule>
Any ideas?
Thanks

Re: Section header in URL - 404

Posted: Wed Aug 21, 2019 7:02 pm
by Dr.CSS
You may want to make EN or ES first as a section header then when you get children pages change them to an internal redirect to the first child page...

Re: Section header in URL - 404

Posted: Thu Aug 22, 2019 7:35 am
by thecarp
@Dr.CSS
EN and ES are Section headers.

There is no problem with redirects. There is a problem with URLs of nested pages.

I need to have a lang identifier in URL, I'm looking for URLs like

Code: Select all

example.com/es/lorem-ipsum.
but it returns 404 Not found.

Currently working URLs are without lang identifier, just

Code: Select all

example.com/lorep-ipsum
, but it isn't what I'm looking for.

So problem isn't in the EN/ES content type, problem is probably in .httacess I've posted, but I don't know where.

Re: Section header in URL - 404

Posted: Fri Aug 23, 2019 10:59 am
by velden
It's strange it results in a 404 as in general CMSMS doesn't care about the url except for the last part of it. This is not true for specific patterns which are defined in routes. This applies to custom urls, defined in a content page too probably.

So if example.com/en/lorem-ipsum works usually example.com/foo/bar/whatever/lorem-ipsum works too

To make sure it indeed something is wrong in your .htaccess you could try something like:

example.com/index.php?page=es/lorem-ipsum

If that does work, than start with the example .htaccess (found in the /docs/ folder as htaccess.txt) and see if it works.