0

my htaccess codes add a slash to the end of all URLs but I just want it to add slashes to files ending with the .php file extension how can I do that?

my htaccess codes :

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^\/(.*?)\/$ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L,NE] RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$ $1.php [NC,L] 

1 Answer 1

2

Could you please try following. Written with shown samples only. Please make sure to clear browser cache before testing your URLs

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} \.php$ [NC,OR] RewriteCond %{REQUEST_URI} ^/seo$ [NC] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L,NE] RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$ $1.php [NC,L] 
Sign up to request clarification or add additional context in comments.

1 Comment

I will open another thread for this problem. You already answered the question I asked.