Page 1 of 1

[solved] htaccess rewrite condition + ListIt2

Posted: Wed Dec 03, 2014 5:48 pm
by HarmO
Hi,
i'm creating a website with CMS made simple version 1.11.11 and i use the listit2 module version 1.4.1 .

Now this module only can generate urls in this form:
http://example.com/listit2/item-alias/page-id

Now, i don't care about the page id which is used to show the correct template,
but since this is a multilingual website i would like listit2 to apear behind my (virtual) language folder:
http://example.com/nl/listit2/item-alias/page-id

so i added 2 rewrite lines in my htaccess file, right before the general rewrite rules of CMSMS.

Code: Select all

RewriteCond %{HTTP_HOST} ^lang/listit2 [NC]
RewriteRule ^nl/listit2(.*)$ listit2$1

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
but that doesn't seem to work since it generates the summary overview instead of a detail page like the content from http://example.com/listit2/page-id

How, can i solve this?

Re: htaccess rewite condition + ListIt2

Posted: Wed Dec 03, 2014 6:22 pm
by velden

Code: Select all

RewriteCond %{HTTP_HOST} ^lang/listit2 [NC]
Makes no sense at all
{HTTP_HOST} would be something like 'www.example.com' and the 'lang' would never match 'nl' either.

Re: htaccess rewite condition + ListIt2

Posted: Thu Dec 04, 2014 9:20 am
by HarmO
indeed,

error of my part while creating my post.
If you change that, it doesn't funtion either:

Code: Select all

RewriteCond %{HTTP_HOST} ^nl/listit2 [NC]
RewriteRule ^nl/listit2(.*)$ listit2$1

Re: htaccess rewite condition + ListIt2

Posted: Thu Dec 04, 2014 9:44 am
by velden
HTTP_HOST still is wrong variable

Re: htaccess rewite condition + ListIt2

Posted: Fri Dec 05, 2014 9:19 am
by HarmO
I removed the condition and just kept this.

Code: Select all

RewriteRule ^nl/referenties(.*)$ refsnl$1
This kind of shows the content i want, but it seams the module is going haywire. For example the generated return link gets double /63/63 at the back.

:-\

don't get it, i can start working with pages in stead of listit2 items, but the i don't have the categories and just the last X of a category...

Would be great if ListIt2 could just have a url_prefix with a "/" in it.

getting frustrated.

Re: htaccess rewite condition + ListIt2

Posted: Fri Dec 05, 2014 12:40 pm
by HarmO
Ok,

i cracked it with the help of Pascal from imust.be
my error was to only do half the work and think that the next rewrite rule would do the rest.
in fact, you have directly pass the link to index.php

my code:

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /

#Virtual folders for listit2
RewriteRule ^nl/referenties(.*)$ index.php?page=refsnl$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>
And for your links generated by the list it 2 module, you use regex replace

More link:

Code: Select all

<a href="{$item->url|regex_replace:"/([r][e][f][s][n][l])/":"nl/referenties"}">more</a>
Return link:

Code: Select all

{$return_link|regex_replace:"/([r][e][f][s][n][l])/":"nl/referenties"}
Note: the url prefix of my listit2 instance is "refsnl"