我的 .htaccess 中有以下代码:
RedirectMatch permanent /en/(.*) /$1
或者
RewriteRule ^en/?(.*)?/?$ $1 [R=301,L,QSA]
使用和/或 RewriteBase /
我想要做的是将每个重定向http://example.com/en/somthing
到http://example.com/somthing
(无论是否带有斜杠)
相反,当我访问http://example.com/en/admin
(不带斜杠)时,我被重定向到http://example.com//admin
(带有 2 个斜杠)当我访问http://example.com/en/admin/
(带有斜杠)时,一切正常.. 其他每个 url 都可以使用尾部斜杠而不是.. 我正在使用symfony2 如果这有帮助,这是我的 routing.yml
deo_secure:
resource: "@DeoSecureBundle/Resources/config/routing.yml"
prefix: /admin
welcome:
pattern: /
defaults: { _controller: AcmeDemoBundle:Welcome:index }
_demo:
resource: "@AcmeDemoBundle/Controller/DemoController.php"
type: annotation
prefix: /demo
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
deo_secure 的路由文件是:
deo_secure_homepage:
pattern: /
defaults: { _controller: DeoSecureBundle:Admin:index }