i’m using .htaccess to create clean urls.
here is a piece of .htaccess file:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/$|.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
RewriteRule ^posts/page/([0-9]+)/$ posts.php?page=$1
RewriteRule ^posts posts.php
it works fine but problem is both urls work!
is there a way to only make site.com/posts/ work and return ‘not found’ on site.com/posts.php(or redirect to site.com/posts/)
think i read somewhere two urls for the same page is bad for seo.
3
Answers
You can create a rewrite rule that returns 404 HTTP code on every “.php” URL :
This is working fine for me. Hope it will work fine for you as well.
To redirect /posts.php to /posts you can use this
If you want to redirect the orignal request to 404 , change the RewriteRule line to this