Php 通过 .htaccess 重写 url [英] Php rewrite url through .htaccess

查看:27
本文介绍了Php 通过 .htaccess 重写 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过使用.htaccess重写

I want to rewrite some url by using .htaccess rewrite

我有这样的网址:

并希望将用户重写为

那么,将会发生的情况是用户会在浏览器中看到 appmedia 但在后端它会访问 zurmo

So, what will happen is users will see appmedia in browser but in the backend it will access zurmo

我是 php 新手,读过一些博客,比如 没有运气

I'm new to php and have read some blogs like this have no luck

也试过这个

RewriteEngine On
RewriteRule ^app/index.php/appmedia/default/login.*$ http://domain.com/app/index.php/zurmo/default/login [R=301,L]

<小时>

它说页面没有正确重定向


it says The page isn't redirecting properly

RewriteEngine On
RewriteRule ^app/index.php/appmedia/default/login.*$ http://mydomainx.com/app/index.php/zurmo/default/login [R=301,L]

推荐答案

您不能使用 [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', 

这篇关于Php 通过 .htaccess 重写 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆