很好和SEO友好的url zend框架php


nice and SEO friendly url zend framework php

使用Zend Framework生成漂亮url的最佳方法是什么?

没有Zend框架和MVC模式,我只使用。htaccess:

RewriteEngine on
RewriteBase /
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d
RewriteRule  ^(.*)$ index.php?request=$1 [QSA,L]

然后用PHP解析请求参数

我现在正在使用Zend框架,并尝试在我的引导中使用zend_route,就像这里建议的那样,并记录在Zend网站上。

我的任务是转换一个请求:example.com/pets-new-york into example.com/index/search/?q=pets%20new%20york (current)

我不能使它工作,我如何管理不存在的文件(-f)和dirs (-d),就像它在第一个。htaccess的例子?更一般地说,用Zend Framework用不存在的目录创建漂亮的url的最佳方法是什么?

请尝试一下。下面的代码将创建SEO友好的url

注意:你必须确保重写apache模块应该在你的服务器上启用

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
如果您需要帮助,请告诉我。