且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Php 通过 .htaccess 重写 url

更新时间:2023-02-24 09:34:09

您不能使用 [R=301] 并期望 URL 不会更改.R 表示重定向.所以它会变成你告诉它的 URL.对于内部重写,您需要将其关闭.

You can't use a [R=301] and expect the URL not to change. R means redirect. So it will change to the URL you told it to. For an internal rewrite you need to leave that off.

如果您的文档根目录中有 .htaccess,那么您应该能够做到这一点.我不知道您的设置如何,但这应该重写 URI.

If you have .htaccess in your document root then you should be able to do this. I don't know how your setup is but this should rewrite the URI.

Options -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^app/index.php/appmedia/default/login/?$ /app/index.php/zurmo/default/login [L]

如果您正在使用 yii 框架,请执行以下操作:

If you are using yii framework do like this:

'urlManager' => array (
 'class' => 'application.core.components.ZurmoUrlManager',
 'urlFormat' => 'path',
'caseSensitive' => true,
'showScriptName' => true,
'rules' => array(
 // Begin Not Coding Standard
 // API REST patterns
 array('zurmo/default/login','pattern' => 'appmedia/default/login',