[英]Url Rewriting not working with cakephp
I have an application , stored in a sub directory of my domain v2. 我有一个应用程序,存储在域v2的子目录中。 I have set up my .htaccess file as follows (in the directory mydomain.com)
我已经如下设置我的.htaccess文件(在目录mydomain.com中)
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ v2/$1 [L]
In my knowledge my urls should be rewritten so they don't contain the /v2 in them. 据我所知,我的网址应该被重写,以便它们中不包含/ v2。 Which does not happen , when I check the value of
$this->base
and $this->webroot
it is www.mydomain.com/v2 when it should be just www.mydomain.com, Is there any way I can change this value. 这不会发生,当我检查
$this->base
和$this->webroot
值时,它是www.mydomain.com/v2,当它应该只是www.mydomain.com时,有什么方法可以更改此设置吗?值。
So What I want to achieve is to rewrite urls so www.mydomain.com/v2/products
appears in address bar as http://mydomain.com/products 所以我要实现的是重写URL,以便
www.mydomain.com/v2/products
在地址栏中显示为http://mydomain.com/products
The only thing those rules do is take a request for www.mydomain.com/products
and internally serve the resource at /v2/products
. 这些规则唯一要做的就是请求
www.mydomain.com/products
并在/v2/products
内部提供资源。 It doesn't do anything about "changing" the URL on the browser. 它与“更改”浏览器上的URL无关。 To do that you must redirect :
为此,您必须重定向 :
RewriteCond %{THE_REQUEST} \ /v2/([^\?\ ]*)
RewriteRule ^ /%1 [L,R=301]
And include that along with the rules that you have. 并将其与您所拥有的规则一起包括在内。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.