Take the 2-minute tour ×
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:

/1/2/3/4/5/[...]

to redirect to this:

/index.php?u=/1/2/3/4/5/[...]

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.

Thanks!

share|improve this question
add comment

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
add comment

Your Answer

 
discard

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.