2

I'm attempting to add a custom RewriteRule in the default htaccess file in Joomla 3, but not having any luck getting it to work.

The end goal is to create a URL with a wildcard subpage, like site.com/features/*, which always loads the base page /features/

In my tests, this rule works properly:

RewriteRule ^features\/?(.*)$ "http://%{HTTP_HOST}/index.php/features" [R=302,L]

However, once I change my flag from R to PT, it gives me a 404:

RewriteRule ^features\/?(.*)$ "http://%{HTTP_HOST}/index.php/features" [PT]

I have tried multiple variations of the rewrite syntax, trying with and without the index.php base, also with RewriteBase and no protocol+host.

In all tests, a 301/302 redirect will work properly, and a passthrough will 404. This tells me it's matching and firing the rule properly, but it's not rewriting on the PT request back to the server.

I'm curious if anyone else here has done this before and can point me in the right direction of what to try next.

Thanks,

4
  • A well-posted question: good attention to formatting, appropriate tags, accurate/distinctive title, clear/correct English, failed coding attempt and its error message -- you are going to fit in nicely here. Please take the tour. – mickmackusa Jan 14 '20 at 22:06
  • What happens if you use the L flag too with PT, like [PT,L] – Zollie Jan 15 '20 at 6:53
  • @mickmackusa Thank you kindly. @Zollie Tried that, no change. L is supposed to be implied with PT, but I tried both to be sure. Since the R flag worked, I want to assume the PT does as well, and it's the second server request for index.php/features that's truly causing the 404. I can't be certain though. – Michael Bourne Jan 15 '20 at 15:22
  • 1
    The really interesting bit in this is that the PT flag is implied when used in .htaccess files. The first thing I'd try to do here is increase the error log level by adding a trace to the mod_rewrite logs: LogLevel rewrite:trace5 That will give you a record of what rewrite is doing, which may give you a better idea of what's happening. – Arlen Jan 15 '20 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.