0

In my website abc.xyz if somebody tries to access a page abc.xyz/about-us.php they are redirected to abc.xyz/about-us. But if you enter a random url abc.xyz/vdsv or abc.xyz/about-us/cdasdf they are redirected to 404 page which should happen like that only, but if somebody tries to use the url abc.xyz/about-us.php/brfgbdrf they are sent back to the about us page and not 404. If somebody tries to use inappropriate url they should be redirected to 404 page. What should I do I am using following code in my htaccess file

RewriteBase /
RewriteRule ^(.+)\.php$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ /$1.php [NC,END] 

# Remove trailing slash in the end
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

Please suggest what should I do

  • Does this answer your question? [Remove .php extension with .htaccess](https://stackoverflow.com/questions/4026021/remove-php-extension-with-htaccess) – Rylee Mar 24 '22 at 06:29
  • 1
    https://httpd.apache.org/docs/2.4/mod/core.html#acceptpathinfo – CBroe Mar 24 '22 at 07:15

0 Answers0