Reputation: 70
I want to add slash end of the url after remove .php from file. For ex. www.xyz.com/abc/
I have used below .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php**strong text**
Upvotes: 1
Views: 427
Reputation: 6692
You might want this
RewriteEngine On
# where the .htaccess file is located (public path from document_root)
RewriteBase /subdir/path/based/on/document_root
# does not apply to existing directories
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite dir-like urls to php script and END rewriting to avoid infinite loop
RewriteRule (.*)/ $1.php [END]
# apply to existing files only
RewriteCond %{REQUEST_FILENAME} -f
# browser redirect to canonical URL
RewriteRule (.*)\.php$ $1/ [L,R=301]
Upvotes: 1