Link to home
Create AccountLog in
Avatar of bradley525
bradley525

asked on

.htaccess rewrite

I am using an .htaccess file that is working correctly, but I need to add another request. In my current .htaccess I pointing all pages to a pages.php...Sometimes I need to point to a different page and it is showing the .php extension. How can I add to my current .htaccess file to remove the .php from any file name that is showing the .php in the url..

Thanks

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.xxxxxx.com/$1 [R,L]
RewriteRule ^([a-zA-Z0-9-z\-]+)$ page.php?id=$1
RewriteRule ^([a-zA-Z0-9-z\-]+)/$ page.php?id=$1

Open in new window

Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

This should help:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

(taken from:
 http://mail-archives.apache.org/mod_mbox/httpd-users/200306.mbox/%3CDAEEJBNAPAICFNHJOIFGEECBCIAA.csebe@fx.ro%3E )
Avatar of bradley525
bradley525

ASKER

I am not sure how to inegrate it with the the code I am currently using ..It errors out when I add that code into the .htaccess file..
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I did try that and the .php is still showing..
You should remove the .php extension from your links!