Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want to have everything that looks like this:


to redirect to this:


unless the requested string is a specific file. So anything that doesn't have a ".", I want to redirect to "index.php?u=[...]". I'll then parse the URI segments in PHP to determine what the user is requesting.

I've been looking around for how to do this, but have only a very rough understanding of regular expressions and have been unable to find an example of how to do it.


share|improve this question

1 Answer 1

Nevermind, figured it out. I found it's easier to match if something is in a string rather than if it isn't in a string, so this is what I came up with:

^.*\..*$ -> /$0

[stop matching if found]

^.*$ -> /index.php?u=$0

Not correct syntax of course, but you can easily adapt it to any number of rerouting systems.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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