Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can I send all traffic to a single index.php file regardless of path or domain? What is the fastest way to do this in nginx.conf? try_files?

Thanks for insight

share|improve this question

2 Answers 2

# Assuming you want static files as well
server {
    listen 80 default_server; # Use default; instead if you're still on 0.7.x.
    try_files $uri /index.php;

    # Standard PHP location block here.
}

# Assuming you do not want static files as well
server {
    listen 80 default_server; # Use default; instead if you're still on 0.7.x.
    location = /index.php {
        # Fastcgi/proxy pass
    }

    location / {
            rewrite ^ /index.php last;
    }
}
share|improve this answer

First answer that came to mind, i suppose you can put this wherever it benefits you the most.

rewrite .* /index.php;
share|improve this answer
    
Ok thanks but where would I put this? I want literally everything to go to index.php (error pages, directories that don't exist) –  ace Nov 1 '10 at 3:12

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.