Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Solution 1:
- `# Remove .php extension
- RewriteRule /.*/?$ - [L]
- RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
- RewriteRule (.*)\.php$ /$1/ [L,R=301]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteCond %{REQUEST_URI} ^/(.+)/$
- RewriteCond %{DOCUMENT_ROOT}/%1.php -f
- RewriteRule ^(.*)/$ $1.php [L]
- # Force trailing slash
- RewriteCond %{REQUEST_FILENAME}.php -f
- RewriteRule .*[^/]$ $0/ [L,R=301]`
- Solution 2:
- `# Remove .php extension
- RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
- RewriteRule ([^/]*)\.php$ /$1/ [L,R=301]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteCond %{REQUEST_URI} ^/(.+)/$
- RewriteCond %{DOCUMENT_ROOT}/%1.php -f
- RewriteRule ^([^/]*)/$ $1.php [L]
- # Force trailing slash
- RewriteCond %{REQUEST_FILENAME}.php -f
- RewriteRule [^/]*[^/]$ $0/ [L,R=301]`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement