php - How remove a trailing slash by using htacces -


we have problem. guys. maybe dealt this. appreciated.

we decided make new website. every webpage made, stored on server looks this: „example.php” however, didn’t want every single url of ours like: „company.com/example.php”, added code .htcaccess, marked „# cut url”:

rewriteengine on # cut url rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([^\.]+)$ $1.php [nc,l] # remove trailing slash rewritecond %{request_filename} !-d rewriterule ^(.*)/$ /$1 [l,r=301] 

works perfectly. removes „.php” part.

however there problem. previous version of our website used wordpress, therefore every single link, can found on internet , leads our company’s site, including past blog entries have slash @ end of each url, i.e. „company.com/stuff/„, copied content our new blog, every entry looks „company.com/stuff.php”, using code have specified above, managed remove „.php” part. whenever accesses blog entry, sees „company.com/stuff” , here’s problem.

we add in .htcaccess redirect old urls, including indexed google. if finds our old links slash @ end, , clicks automatically redirected blog entry same content on our new website. let’s clicks on „company.com/stuff/„ , automatically takes him „company.com/stuff” (actually „company.com/stuff.php” aforementioned code removes „php” part.)

and we’re not sure how that. we’ve been trying find solutions, people suggested piece of code, removes trailing slash, not work, put here , it’s marked „remove trailing slash”.

please, maybe has solution. have standalone php, no frameworks.

rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ([^\.])+/?$ $1.php [nc,l] 

you want add r=301 flag in there well, i'm not sure - that's you.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -