Arnaud Lier Posted February 6, 2019 Share Posted February 6, 2019 Hello, I want to delete all .php extensions in the url (except index.php). My actual .htaccess file : ### BEGIN - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ### <IfModule mod_rewrite.c> RewriteEngine on # RewriteBase is set to "/" so rules do not need updating if the # installation directory is relocated. It is imperative that # there is also a RewriteCond rule later that can effectively get # the actual value by comparison against the request URI. # # If there are _any_ other RewriteBase directives in this file, # the last entry will take precedence! RewriteBase / RewriteCond %{THE_REQUEST} ^GET\s.+\.php [NC] RewriteCond %{REQUEST_URI} !^/index\.php [NC] RewriteRule ^(.+)\.php$ /$1 [NE,R=301,L,NC] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/$1.php -f RewriteRule ^(.*?)/?$ $1.php [L] </IfModule> ### END - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ### But this happens when I try to go on "Espace Client" 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 7, 2019 Share Posted February 7, 2019 Try this instead, have tested it also RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php [NC,L] 0 Quote Link to comment Share on other sites More sharing options...
Arnaud Lier Posted February 9, 2019 Author Share Posted February 9, 2019 I can't login to my admin page anymore ! @steven99 0 Quote Link to comment Share on other sites More sharing options...
WHMCS ChrisD Posted February 10, 2019 Share Posted February 10, 2019 @ZeProf2Coding have you tried Fully Friendly ReWrite URLs as outlined at https://docs.whmcs.com/Friendly_URLs 0 Quote Link to comment Share on other sites More sharing options...
Arnaud Lier Posted February 10, 2019 Author Share Posted February 10, 2019 Yes but this doesn't delete the ".php" extensions 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 11, 2019 Share Posted February 11, 2019 Try this: # remove .php from browser address bar via redirect RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC] RewriteRule ^ /%1 [R=301,NE,L] # rewrite requests without .php to their real file RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.+?)/?$ $1.php [L] Tested within my dev admin without issue, however, the first one that removes the .php via a redirect will cause pretty much every page load within WHMCS to do a redirect to the version without .php and that can slow down page loads. 0 Quote Link to comment Share on other sites More sharing options...
Arnaud Lier Posted February 11, 2019 Author Share Posted February 11, 2019 And my file : ### BEGIN - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ### <IfModule mod_rewrite.c> RewriteEngine on # RewriteBase is set to "/" so rules do not need updating if the # installation directory is relocated. It is imperative that # there is also a RewriteCond rule later that can effectively get # the actual value by comparison against the request URI. # # If there are _any_ other RewriteBase directives in this file, # the last entry will take precedence! RewriteBase / # Remove .php from browser address bar via redirect RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC] RewriteRule ^ /%1 [R=301,NE,L] # Rewrite requests without .php to their real file RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.+?)/?$ $1.php [L] </IfModule> ### END - WHMCS managed rules - DO NOT EDIT BETWEEN WHMCS MARKERS ### 0 Quote Link to comment Share on other sites More sharing options...
Arnaud Lier Posted February 11, 2019 Author Share Posted February 11, 2019 @WHMCS ChrisD Can you help me please? 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted February 12, 2019 Share Posted February 12, 2019 For some reason, maybe security related, WHMCS requires .php on the file name for at least login.php where other ones worked . As it may require the same for other files, I would not recommend to remove the .php as it can cause unexpected issues. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 13, 2019 Share Posted February 13, 2019 15 hours ago, steven99 said: For some reason, maybe security related, WHMCS requires .php on the file name for at least login.php where other ones worked . As it may require the same for other files, I would not recommend to remove the .php as it can cause unexpected issues. it's probably Friendly URLs related more than security, and i'd go along with the idea that it probably isn't worth attempting to do this. 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.