1

In J3 i used specific rewrite rules in .htaccess that worked fine but doesn't seem to work in J4. Here's an example :

RewriteRule ^metier/([a-zA-Z0-9-_]+)\.html$ /index.php?option=com_content&view=article&id=18&Itemid=102&filtrefonction=$1 [QSA,L]

In J4, when I use this URL in my browser it works fine :

/index.php?option=com_content&view=article&id=18&Itemid=102&filtrefonction=$1

but when I try the rewritten URL :

/metier/btp-construction.html

I get a 404 error Page not found... RewriteEngine is On of course and the rules in the .htaccess file.

I have tried to change the rule this way :

RewriteRule ^metier-([a-zA-Z0-9-_]+)\.html$ /index.php?option=com_content&view=article&id=18&Itemid=102&filtrefonction=$1 [QSA,L]

and try to call the url

/metier-btp-construction-usines-infrastructures-tp.html

but it gives the same result : an error 404 :/

Does anyone have any idea about this issue? Thanks for any answer!

3
  • 1
    I had a similar issue and ended up using the Joomla Router in favour of htaccess [joomla.stackexchange.com/questions/33283/…
    – cappu
    Commented Sep 19, 2023 at 17:52
  • "when I use this URL in my browser it works fine : /index.php?option=com_content&view=article&id=18&Itemid=102&filtrefonction=$1" - Presumably you replaced $1 with btp-construction (in your example)? Where exactly have you put this rule in the .htaccess file? A rule like this would need to go near the top of the .htaccess file, before the Joomla code block (front-controller pattern).
    – MrWhite
    Commented Sep 19, 2023 at 21:08
  • Your regex character class ([a-zA-Z0-9-_]) is a little ambiguous (although should be OK in this case as it happens) since you have an unescaped literal hyphen that is not the first or last character. It would be "safer" to move the literal hyphen to the last position (switching the last two characters), ie. [a-zA-Z0-9_-]
    – MrWhite
    Commented Sep 19, 2023 at 21:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.