首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Apache Typecho框架启用地址重写

Apache Typecho框架启用地址重写

作者头像
王瑞MVP
发布2022-12-28 18:08:29
发布2022-12-28 18:08:29
8790
举报

地址重写有利于SEO优化,开启地址重写可以去掉Typecho框架中的index.php后缀,该后缀如下。

第一步,进到apache配置文件目录下cat /etc/httpd/conf/httpd.conf 加入以下模块。

代码语言:javascript
复制
LoadModule rewrite_module modules/mod_rewrite.so

第二步,配置空间权限,将AllowOverride None改为AllowOverride All

代码语言:javascript
复制
# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

第三步,在网站根目录新建vim /var/www/html/.htaccess写入重写规则。

代码语言:javascript
复制
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

第四步,启用地址重写。

再次访问即可完成。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-12-28,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档