In my server I kept signup.php and in .htaccess I kept this thing -

RewriteRule ^/registration/?$ http://www.example.com/signup$1 [R]

But this is not redirecting www.example.com/registration/ to www.example.com/signup/ However I tried with other things like -

RewriteRule ^/registration/?$ signup.php$1 [R]

and also -

RewriteCond %{REQUEST_URI} ^registration/$ [NC] RewriteRule ^(.*) http://example.com/signup [R=301,L

But nothing is working out. It's showing me 404 error message. I am using Ubuntu 14.04 in Windows Azure server running Apache 2.2.22

1 Answer 1


I see some problems with your rewrite rules.

  • You don't explicitly turn on mod_rewrite with RewriteEngine On
  • When using rewrite rules in your .htaccess file the slash at the beginning of them is assumed. Having a slash at the beginning of the rule will prevent rewrite from executing the rule. (This is different than if the rule were in httpd.conf where the slash at the beginning is required.)
  • You have an extraneous $1 in your first rule. Having $1 should be a back reference to whatever is in parenthesis in the first part of the rule. There are no parenthesis, so that rule is not going to work right.
  • When redirecting with mod_rewrite, I recommend always using the L flag to ensure that it is the last rewrite rule triggered.
  • You almost always want to specify the "permanent" type of redirect with R=301 so that it doesn't do temporary redirect which are less SEO friendly.
  • Your last rule should be on multiple lines.
  • Your last rule is missing a closing ].

I would recommend first trying to use a simple redirect directive for something this simple:

redirect permanent /registration /signup

If that doesn't work you can fix your rewrite rule:

RewriteEngine On
RewriteRule ^registration/?$ /signup [L,R=301]

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.