Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force language segment (preVar) #28

Closed
fsuter opened this issue Feb 12, 2016 · 7 comments
Closed

Force language segment (preVar) #28

fsuter opened this issue Feb 12, 2016 · 7 comments

Comments

@fsuter
Copy link
Contributor

fsuter commented Feb 12, 2016

I'm trying out RealURL 2.0 with TYPO3 7 (7.6.3-dev to be precise).

My RealURL config is here: https://gist.github.com/fsuter/a96c09c5d8ad1e4b13ac

When using RealURL 1.x and TYPO3 6.2 I could make it so that my URLs always included the language segment, even in the default language. With RealURL 2.0, this is no longer true. The URLs in the default language dont' have the language segment (which would have been "fr" in my case). Is something wrong with my configuration?

I did some debugging with Xdebug and it seemed to me that "fr" was always added while going through \DmitryDulepov\Realurl\Encoder\UrlEncoder::encodeUrlParameterBlockUsingValueMap() but then it does not appear in the typolinks anymore.

URLs to translations have proper language segments.

@dmitryd
Copy link
Owner

dmitryd commented Feb 15, 2016

Thanks for the report!

I guess it can be related to the valueDefault use. Previous version of RealURL used separate caches for encoding and decoding. So your visitors could come to the site using /foo/bar but the proper generated link os /fr/foo/bar/. Due to different caches incoming and generated links could be different. Newer versions use the same cache, so if users come through /foor/bar, encoding will also return /foor/bar. On one hand such behavior helps to prevent duplicate content. On the other hand it is not consistent with previous behavior.

This is just an idea. I will investigate and see what can I do about it. Probably, I should change handling of valueDefault to a redirect but I am not sure yet.

Thanks a lot for testing and reporting!

@fsuter
Copy link
Contributor Author

fsuter commented Feb 22, 2016

Thanks for your answer. I actually found a way around this, which seems correct to me and doesn't imply any changes in RealURL (although it does mean a change of behaviour, as you mention). If I force the setting of the "L" GET variable using the following TypoScript:

config {
    defaultGetVars {
        L = 0
    }
}

all my links include the language segment in the default language.

@dmitryd
Copy link
Owner

dmitryd commented Mar 1, 2016

Note for myself: needs documentation!

@dmitryd
Copy link
Owner

dmitryd commented Mar 3, 2016

Documentation is done, closing the issue.

@dmitryd dmitryd closed this as completed Mar 3, 2016
@lsascha
Copy link

lsascha commented May 8, 2017

Sorry to post here, but i have a bit of trouble with this.
I have it working that all links get the language part included, however they are still accessible without that part. And for google this means its duplicate content. Is there any way to disallow accessing it without the language part? Using Realurl 2.0

Thanks.

@dmitryd
Copy link
Owner

dmitryd commented May 10, 2017

Is there any way to disallow accessing it without the language part?

Use rewrites (mod_rewrite for Apache or nginx rewrites). You can always check if language segment is included or not and 301-redirect accordingly.

@fnagel
Copy link

fnagel commented Sep 28, 2017

Redirect URLs without language prefix. Might be useful to document this somewhere:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/([a-z]{2})/(.*)$
RewriteRule ^(.*)$ /en/$1 [L,R=301]
RewriteRule ^$ /en/ [L,R=301]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants