Love2c0de Posted February 28, 2014 Share Posted February 28, 2014 (edited) Good afternoon, I'm having a really weird problem with my attempt at re-writing URL's. I'm trying to remove the .php extension from my filename within the URL. It works fine with pages 'portfolio.php, terms.php and promise.php' but not any of the other pages. The other pages send me to a redirect loop error. Here is my rewrite rules: RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME}.php -fRewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L] filenames are as guessed, index.php, services.php, contact.php etc, as you can see only those certain pages listed above work. Does anyone know why? Thank you for your time. Kind regards, L2c Edited February 28, 2014 by Love2c0de Quote Link to comment https://forums.phpfreaks.com/topic/286614-remove-php-extensions/ Share on other sites More sharing options...
Ch0cu3r Posted February 28, 2014 Share Posted February 28, 2014 If all you're doing is dropping the extension then try just enabling Multiviews Options +Multiviews Quote Link to comment https://forums.phpfreaks.com/topic/286614-remove-php-extensions/#findComment-1471073 Share on other sites More sharing options...
Love2c0de Posted March 6, 2014 Author Share Posted March 6, 2014 Hi Ch0cu3r, Thank you for the reply and sorry for the late reply. I ended up taking another route. I did look at the link you provided but it was too complicated at the time. Would you be able to help me solve my next problem? I used this code to get what I needed: RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME}.php -fRewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L] I have a 'portfolio.php' page with some project links. When those links are clicked it accepts a GET variable and pulls the relevant information from the database - displaying it on 'project.php'. So project.php acts as a template for different content. How can I modify my .htaccess rules to compensate for when there is a GET variable passed? Thank you for your time. Kind regards, Tom Quote Link to comment https://forums.phpfreaks.com/topic/286614-remove-php-extensions/#findComment-1471652 Share on other sites More sharing options...
Ch0cu3r Posted March 6, 2014 Share Posted March 6, 2014 (edited) How can I modify my .htaccess rules to compensate for when there is a GET variable passed? Apply the QSA (Query String Append) flag on your rewrite rule RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L,QSA] Edited March 6, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/286614-remove-php-extensions/#findComment-1471653 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.