Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. Solution 1:
  2. `# Remove .php extension
  3. RewriteRule /.*/?$ - [L]
  4. RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
  5. RewriteRule (.*)\.php$ /$1/ [L,R=301]
  6.  
  7. RewriteCond %{REQUEST_FILENAME} !-f
  8. RewriteCond %{REQUEST_FILENAME} !-d
  9. RewriteCond %{REQUEST_URI} ^/(.+)/$
  10. RewriteCond %{DOCUMENT_ROOT}/%1.php -f
  11. RewriteRule ^(.*)/$ $1.php [L]
  12.  
  13. # Force trailing slash
  14. RewriteCond %{REQUEST_FILENAME}.php -f
  15. RewriteRule .*[^/]$ $0/ [L,R=301]`
  16.  
  17. Solution 2:
  18. `# Remove .php extension
  19. RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
  20. RewriteRule ([^/]*)\.php$ /$1/ [L,R=301]
  21.  
  22. RewriteCond %{REQUEST_FILENAME} !-f
  23. RewriteCond %{REQUEST_FILENAME} !-d
  24. RewriteCond %{REQUEST_URI} ^/(.+)/$
  25. RewriteCond %{DOCUMENT_ROOT}/%1.php -f
  26. RewriteRule ^([^/]*)/$ $1.php [L]
  27.  
  28. # Force trailing slash
  29. RewriteCond %{REQUEST_FILENAME}.php -f
  30. RewriteRule [^/]*[^/]$ $0/ [L,R=301]`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement