I know how to rewrite URLs to redirect to a page.

When the / is not at the end of www.example.com/user/myUserName the redirect works:

RewriteRule /$ /user/index.php

When I write RewriteBase / the above rule does not work, but a 404 error.

How to add a / at the end of www.example.com/user/myUserName/ and still redirect to /user/index.php.

This can be written into the .htaccess or httpd.conf.

  • @johnConde I am hoping people provide an answer to my question
    – Jean
    Feb 27, 2011 at 19:17
  • 1
    Me too. :)
    – John Conde
    Feb 27, 2011 at 19:20
  • @johnConde that would totally nullify your purpose of redirecting this question from serverfault to prowebmaster
    – Jean
    Feb 27, 2011 at 19:25
  • 1
    I didn't do it. The moderators or users of ServerFault did it. They did it because this question belongs here, not at that site. And believe it or not questions get answered here, too. ;)
    – John Conde
    Feb 27, 2011 at 19:28
  • FWIW, the mention of RewriteBase with regards to the above directive is irrelevant. Since the RewriteRule substitution is root-relative (ie. starts with a slash), the value of RewriteBase is not used.
    – MrWhite
    Dec 10, 2015 at 15:26

2 Answers 2


Your english seems a bit confusing...

But from what I gather, the regular expression in your pattern isn't correct.

I belive you're trying to match everything to /user/index.php so try it this way:

RewriteRule /(.*)$ /user/index.php
  • That would hold good for www.MyDomainName.com/x1e, would it be good for if the domain is www.MyDomainName.com/x1e/
    – Jean
    Feb 28, 2011 at 7:42
  • Absolutely, that catches all requests and sending them to /user/index.php
    – Dani
    Mar 6, 2011 at 12:09

The problem is that you're referring to a directory that doesn't exist. Is the .htaccess file in the root directory of you're server?

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.