2

假设我有一个运行 CakePHP 的站点,并且我有前缀“产品”。

我有很多带有 URL 的页面,例如:

http://mysite.com/produt/blue-shirt/details
http://mysite.com/produt/blue-shirt/order
http://mysite.com/produt/skate/details
http://mysite.com/produt/sun-glasses/vendors

现在我需要使用一个域,比如http://mysite-blue-shirt.com/蓝衫产品的“快捷方式”,我的 URL 将变为:

http://mysite-blue-shirt.com/details
http://mysite-blue-shirt.com/order

我需要做什么?

我认为这与.htaccess网站根目录外的app目录有关。

这是当前的语法:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>
4

3 回答 3

1

我认为您需要创建自己的自定义路由类。检查这个: http: //mark-story.com/posts/view/using-custom-route-classes-in-cakephp

于 2010-10-27T18:17:53.537 回答
1

Try this:

<IfModule mod_rewrite.c>
   RewriteEngine on

   RewriteCond    %{HTTP_HOST} ^mysite-blue-shirt\.com
   RewriteCond    %{REQUEST_URI} !^/product/blue-shirt
   RewriteRule    ^(.*)$ app/webroot/product/blue-shirt/$1 [L]

   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

The first line checks the site's name. The second one checks if it has already not been re-written to blue-shirt. The final line carries out the rewrite.

于 2010-11-28T10:19:56.887 回答
0

要让外界看到这一点,您需要注册 mysite-blue-shirt 和所有其他变体。

于 2010-10-27T14:22:00.553 回答