I need to place a rewrite rule in my .htaccess file so that requests for


are redirected to:


So I have tried adding this rule into the .htaccess file:

RewriteRule ^jbossas/jboss-configuration jboss-server/jboss-configuration [R=301,L]

but it didn't work

RewriteRule ^/jbossas/jboss-configuration jboss-server/jboss-configuration [R=301,L]

didn't work either.

Is the rule correct? Or do I need to request a Web server restart to my Provider for changes to take effect? Note, I'm running Joomla 3 Web site.

  • 1
    "it didn't work" - In what way did it not work? Did you get an error? Incorrect redirect? Nothing? By itself, the directive you posted would likely result in a malformed redirect. Presumably you have a RewriteEngine directive? Please include your entire .htaccess file.
    – MrWhite
    Commented Dec 13, 2018 at 10:58

1 Answer 1


Assuming you have a RewriteEngine On directive then...

RewriteRule ^jbossas/jboss-configuration jboss-server/jboss-configuration [R=301,L]

By itself, this directive would likely result in a malformed redirect, since the directory-prefix would be prefixed to the relative substitution string. For external redirects, the substitution string should start with a slash. However, this would also depend on whether you have a RewriteBase directive set, as this dictates the URL-path that is used, overriding the directory-prefix.

If you are not getting a redirect at all then it's likely that the directive has been put in the wrong place. An external redirect like this would need to go near the top of your .htaccess file, before the Joomla front-controller.

Not also, that the above regex matches any URL-path that simply starts /jbossas/jboss-configuration, not the URL exactly - if that is an issue?

RewriteRule ^/jbossas/jboss-configuration jboss-server/jboss-configuration [R=301,L]

didn't work either.

This would only match if the directive was used in a server (or virtualhost) context. In a server context, the RewriteRule directive matches against the full URL-path, including the slash prefix. In a directory (or .htaccess) context it matches against the URL-path less the directory-prefix, so no slash prefix.

Try the following at the top of your .htaccess file:

RewriteEngine On
RewriteRule ^jbossas/jboss-configuration$ /jboss-server/jboss-configuration [R=302,L]

The RewriteEngine directive is not required if it is already present in the file. (It is more logical to have the RewriteEngine directive once at the very top, but that is not required.)

This is a 302 (temporary) redirect. Change this to a 301 (permanent) redirect - if that is the intention - only after you have confirmed that it works OK. This is to avoid the browser caching erroneous redirects whilst testing.

You will need to clear your browser cache before testing.

  • 1
    Thanks that worked! Apologizes for not being clear in my question. I didn't get any error but the rewrite rule was simply not effective. Commented Dec 13, 2018 at 11:21

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.