Jump to content


Photo

remove .php extensions


  • Please log in to reply
3 replies to this topic

#1 Love2c0de

Love2c0de

    Advanced Member

  • Members
  • PipPipPip
  • 366 posts
  • LocationThe Pleiades
  • Age:23

Posted 28 February 2014 - 11:23 AM

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 On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.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 by Love2c0de, 28 February 2014 - 11:23 AM.


#2 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 2,247 posts

Posted 28 February 2014 - 11:34 AM

If all you're doing is dropping the extension then try just enabling Multiviews

Options +Multiviews


#3 Love2c0de

Love2c0de

    Advanced Member

  • Members
  • PipPipPip
  • 366 posts
  • LocationThe Pleiades
  • Age:23

Posted 06 March 2014 - 10:53 AM

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 On
RewriteBase /
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.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



#4 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 2,247 posts

Posted 06 March 2014 - 11:11 AM

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 by Ch0cu3r, 06 March 2014 - 11:17 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com