mod rewrite - Apache mod_rewrite rules adding trailing slashes when not expected -
i trying mod_rewrite rules work particular section of site. rules should
- add trailing slash main /test/ section if 1 missing.
- add trailing slash urls under /test/ folder if url not point file or folder.
- reroute urls do.php file if url not point file, folder, or under "special folder.
these rules:
## append / url if trailing slash missing. rewriterule ^/test$ /test/ [r=301,l] ## append / end of every url under test if not file or folder , not have trailing slash rewritecond %{document_root}/test/$1 !-f rewritecond %{document_root}/test/$1 !-d rewritecond %{request_uri} !/test/(.+)/$ rewriterule ^/test/(.+)$ /test/$1/ [l,r=301] ## reroute urls do.php unless folder, file, or under special folder rewritecond %{document_root}/test/$1 !-d rewritecond %{document_root}/test/$2 !-f rewritecond %{request_uri} !/test/special/.* rewriterule ^/test/(.+)$ /test/do.php [l]
while rules not causing issue when go /test/special/index.php, when try open /test/special/js/jquery.js, rewrites trailing slash of /test/special/js/jquery.js/ instead.
Comments
Post a Comment