地址重写有利于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]
第四步,启用地址重写。
再次访问即可完成。