Deesen / YAMS

Original Fork of YAMS (Yet Another Multilingual Solution for Evolution CMS)
http://modxcms.com/forums/index.php/board,381.0.html
8 stars 7 forks source link

Transparent RewriteRule #26

Open Neoziox opened 5 years ago

Neoziox commented 5 years ago

Hi!

I know it's works without YAMS. So I wonder why it's doesn't work for this website.

Here, the .htaccess file config:

#Options +FollowSymlinks
RewriteEngine On
RewriteBase /

# Fix Apache internal dummy connections from breaking [(site_url)] cache
RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
RewriteRule .* - [F,L]

# Exclude /assets and /manager directories and images from rewrite rules
RewriteRule ^(manager|assets|js|css|images|img)/.*$ - [L]
RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]

# Personal request
RewriteRule ^fr/actualites/(.*)$ fr/actualites?filter=$1 [L,N]

# Redirect from mydomain.com/rootname to mydomain.com/rootname/
RewriteRule ^en$ en/ [R=301,L]
RewriteRule ^fr$ fr/ [R=301,L]
RewriteRule ^de$ de/ [R=301,L]

# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^en/(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^fr/(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^de/(.*)$ index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

In a "normal" case (without YAMS), when I go to this page: /fr/actualites/first-article.html The redirection is transparent and I stay on this page, this exactly the same URL and I have an access to the $_GET['filter'] (in my actualites Resource) -> $_GET['filter'] = 'first-article.html'

But, here, I'm redirected to: /fr/actualites?filter=first-article.html

Am I clear? So, how to change this?

Help!

Deesen commented 5 years ago

I don´t understand and I am no htaccess-professional. But I can try to help. You say you are redirected to

/fr/actualites?filter=first-article.html

so your rule

RewriteRule ^fr/actualites/(.*)$ fr/actualites?filter=$1 [L,N]

seems to work as expected?

Maybe try removing N so the end of line is just [L]? I am refering to https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_n

Neoziox commented 5 years ago

Indeed. But if you look the normal rule

RewriteRule ^fr/(.*)$ index.php?q=$1 [L,QSA]

you are not redirect to index.php?q=something

I want the same behavior. If I'm on /fr/actualites/something.html I want to keep this URL.

Am I more clear?

Deesen commented 5 years ago

I am just guessing.. maybe something like

RewriteRule ^fr/actualites/(.*)$ index.php?q=actualites/&filter=$1 [L,QSA]

Neoziox commented 5 years ago

Yes. I'm already try this and guess what. I'm redirect to: /fr/actualites?filter=something.html

Deesen commented 5 years ago

Then I do not understand your needs, you need to give more clear details. Maybe a link to your website..

Neoziox commented 5 years ago

In the webpage /fr/actualites/ I have several links which looks like /fr/actualites/something.html But in Evo Manager, I have only one ressource: /fr/actualites/ in which I have a snippet that retrieves the information in the URL. Is this more clear? PS I don't have a link to the website yet. Sorry.

Neoziox commented 5 years ago

@Deesen If not, in your opinion, where can I post my question or who can I contact who could help me (someone you may know maybe)?

Deesen commented 5 years ago

Maybe on Slack Evo-Channel or on stackoverflow.com?

But maybe it would be easier to change your snippet to use $_POST instead of $_GET. You could send a form/ post-data to /fr/actualites/. This way you can be sure you stay on the same resource without getting redirected, while having the filter-data available in $_POST. Did I understand you correct? Does that make sense?

Neoziox commented 5 years ago

I have a personal database (in a TV with MultiTV). Each entry of this database can be a specific page in the same way that each resource of Evo is a page. So, in the same way that each resource have an alias as access to its page, I want every entry in the database to have its page with its alias. To be able to do that, I use the same method that Evo: $_GET. As I said, I already used this method but without YAMS. In some way, it's different but I don't understand why and where. I'm really sorry I was not clear enough before.

Deesen commented 5 years ago

Ah ok, I got it now ;-). Not sure how to solve it yet but maybe you want to try:

Neoziox commented 5 years ago

Damned! It doesn't work! I believed it.