AJFMEDIA
AJFMEDIA

Reputation: 2123

re written url causing duplicate pages

I have tried to rewrite my url so that it removes php extention and adds trailing slash.

I can access the page this way now.. lovelakedistrict.com/lake-district-cottages/

but i can also access it via this way:

lovelakedistrict.com/lake-district-cottages.php

how can I remove the php extention for good. this my htaccess

Options +FollowSymlinks
Options +Indexes
RewriteEngine on
RewriteBase /



RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]




RewriteRule ^lake-district-cottages/cottages/([0-9]) lake-district-cottages.php?cottages=$1

Upvotes: 0

Views: 56

Answers (1)

Lekensteyn
Lekensteyn

Reputation: 66465

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^([^.]+)\.php$ /$1 [R=301,L]

Upvotes: 1

Related Questions