c006 / yii2-alias-url
支持别名URL。即SEO URL。
2.2
2016-07-29 18:04 UTC
This package is not auto-updated.
Last update: 2024-09-14 16:55:27 UTC
README
管理您网站重写路径的绝佳方式!
安装
通过 composer 安装此扩展是首选方式。
运行以下命令
php composer.phar require --prefer-source "c006/yii2-alias-url" ">=2.1"
或添加以下内容到您的 composer.json
文件的要求部分。
"c006/yii2-alias-url": ">=2.1"
require
: {"c006/yii2-alias-url": "*"}
接下来,检查数据库连接是否已设置
运行以下命令以设置表。
$ yii migrate --migrationPath=@vendor/c006/yii2-alias-url/migrations
或 -- 如果使用yii2-console,则使用易于使用的迁移替代方案
$ yii migrate2 m000000_000000_c006_url
配置
基本的 "config/web.php"
高级 "config/main.php"
'components' => [
...
...
...
'urlManager' => [
'enablePrettyUrl' => FALSE,
'showScriptName' => FALSE,
],
],
'modules' => [
...
...
...
'alias' => [
'class' => 'c006\url\Module',
'is_frontend' => {TRUE/FALSE}
],
],
请勿使用 .htaccess
**在您的主机/虚拟主机文件中使用 Mod_Rewrite**
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 0
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule (assets|images|css|videos)($|/) - [L]
RewriteCond %{REQUEST_URI} !^/index
RewriteRule (.*) /index.php$1
RewriteRule . /index.php [L]
</IfModule>
这适用于使用高级时的前端和后端。
使用方法
转到
/alias
点击 > 创建URL
public => abc
private => site/about
现在 /abc
将显示 site/about
注意私有可以具有动态查询字符串。
public => abc
private => site/about?id=123
评论/建议/帮助
使用问题票证提供任何有用的反馈、请求或问题。
谢谢。