1

maybe someone can help me with this problem. I want to remove the php extension. (i want to use grabaperch with nginx). This is the apache rewrite rule:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ $1.php [L] 

Redirect 301 /portrait /portrait/zu-meiner-person.php

I use nginx 0.8.54 with php5-fpm on ubuntu 11.04.

URLs like this /folder/file.php should look like this /folder/file/ . URLs like this /folder/ should display the index.php

2

1 Answer 1

1

After a lot of trial and error, i managed to end up to a working solution.Check below

try_files $uri $uri.php;
rewrite ^(.*)$ $uri.php;

Would be nice though if someone know how to add '/' in the end of the uri. Instead of example.com/products.php to become example.com/products/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.