Malibu Posted January 29, 2016 Share Posted January 29, 2016 Dear Community Does anybody know how to achieve the following by modifying the .htaccess file in order to output SEF URLs: a) remove the file extension .php and add instead a trailing slash Example: instead of http://www.my-domain.tld/whatever.php, new http://www.my-domain.tld/whatever/ b) redirect the /index.php in the root to the domain Found this in another thread of the community: RewriteCond %{THE_REQUEST} ^GET\s.+\.php [NC] RewriteRule ^(.+)\.php$ /$1 [NE,R=301,L,NC] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/$1.php -f RewriteRule ^(.*?)/?$ $1.php [L] But it does not add a trailing slash at the end of the rewritten files and the redirection of the /index.php in the root I've put in place is not working properly since the user can still call http://www.my-domain.tld/index although entering http://www.my-domain.tld/index.php is redirected correctly. Many thanks in advance! 0 Quote Link to comment Share on other sites More sharing options...
zomex Posted January 31, 2016 Share Posted January 31, 2016 Hello, htaccess can be a pain as some code won't work on every server. I personally use the following to redirect from /index.php to / but I use it for non-WHMCS pages, it may work for you: RewriteRule ^(.*)index\.(php|html?)$ /$1 [R=301,NC,L] 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.