Hi all,

Is mod_rewrite supported at the site level on DH? If so, maybe I’m not doing things right. If not, then I need another solution.

I want the following URL:
to resolve to…

“world” in the above example might be any arbitrary string.

I added the following to my .htaccess file in my site’s root dir, but no success (404 error):

RewriteEngine On
RewriteRule ^/hello/(.*) /script.php?hello=$1

Thanks in advance for helping out an apache novice!


Unfortunately, I don’t know how to do .htaccess rewrite (though there are plenty of tutorials that can be found via a Google search). What I can tell you, however, is that mod_rewrite is support at the site level on DH.
I don’t work here. I’m just your typical support forum volunteer.

It’s probably due to the lack of a RewriteBase directive.


RewriteEngine On RewriteBase / RewriteRule ^hello/(.*) /script.php?hello=$1 [QSA]Now, the RewriteBase directive tells Apache what “virtual directory” we are rewriting for so it can re-build the URL properly. You should note that I have removed the value of RewriteBase from the beginning of the regexp as a result.

I added the QSA flag, you might want to remove it.
With QSA: /hello/world/?version=2 becomes /script.php?hello=world/&version=2
Without QSA: /hello/world/?version=2 becomes /script.php?hello=world/

When a substitution occurs for a new URL, this module has to re-inject the URL into the server processing. To be able to do this it needs to know what the corresponding URL-prefix or URL-base is. By default this prefix is the corresponding filepath itself. But at most websites URLs are NOT directly related to physical filename paths, so this assumption will usually be wrong! There you have to use the RewriteBase directive to specify the correct URL-prefix.
:cool: Perl / MySQL / HTML CSS

That’s it exactly! I had tried adding “RewriteBase /” since my original post, but not from the regexp. Did as you suggest and all is working well.

Thanks for your help!