I have some external links to my site that referrer to pages with a file extension and a trailing slash after that eg
http://example.com/folder/page.php/
I can not change these links, but I would like to 301 redirect those links to this format instead:
http://example.com/folder/page/
I've tried this, but it doesn't work:
RewriteRule ^(.*)\.php\/$ /$1/ [R=301,L]
Any help is appreciated.
Try this in your /.htaccess file
RewriteEngine On
RewriteCond %{THE_REQUEST} /([^.]+)\.php/? [NC]
RewriteRule ^ /%1/ [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /$1.php [L,NC]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.