.htaccess - Trailing slash removal opening full directory -


i'm trying remove trailing slash of urls. whatever htaccess script lines try, redirects seems full server directory. example.com/xyz/ weirdly redirects example.com/customers/b/7/3/example.com/httpd.www/xyz – not found.

basically, i'm not using subdirectories getting data out of database according what's last string after last slash. "not found" error ok, because there isn't existing folder.

i'm new htaccess, trying out whatever lines found.

rewrite opens index.php , not folder (which works fine without trailing slash, engine on):

rewriterule ^([a-za-z0-9_-]+)$ index.php?$1 rewriterule ^([a-za-z0-9_-]+)/$ index.php?$1 

i failed using remove slash:

rewriterule ^(.+)/$ /$1 [r=301,l] 

so i'm trying is:

  • open url index.php. example example.com/xy doesn't redirect show/open index.php (i think achieved above 2 lines)
  • while doing so, i'm trying remove trailing slash e.g. example.com/xy/, example.com/xy , example.com/xy/ both show/open index.php

thanks wisdom!

you can do:

rewriteengine on  rewritecond %{request_filename} !-d rewritecond %{the_request} \s(.+?)/+[?\s] rewriterule ^(.+?)/$ /$1 [r=301,l]  rewriterule ^([\w-]+)/?$ /index.php?$1 [l,qsa] 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -