简体   繁体   中英

Zend Framework 1 - do not display trailing slash in URL

I know there are various questions out there and various solutions on how to achieve this via .htaccess

The question is simple - when a user enters a url like

www.abc.com/users/index/

It should appear as

www.abc.com/users/index

I read somewhere that using htaccess for this purpose is an overkill and it should be done in the predispatch or preprocess method in Zend.

I am not sure how that can be done.

Has anyone done this without using .htaccess

Thanks

I don't think that .htaccess is an overkill. Running entire application (to predispatch) is quite expesive.

But to answer your question: extend the Zend_Controller_Plugin_Abstract http://framework.zend.com/manual/1.12/en/zend.controller.plugins.html

In preDispatch method you can check the URL: $request->getRequestUri();

Can you please try the below code:

DirectorySlash Off

Add this code in your .htaccess file and check if it's working for you or not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM