通常癿URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里面癿index.php,通过URL重写的方式可以达到。返种效果,通常需要朋务器开启URL_REWRITE模块才能支持。
Apache癿配置过程:
1、httpd.conf配置文件中加载了mod_rewrite.so模块(去掉前面的#号)
2、AllowOverride None 将None改为 All(注意有两处)
3、确保URL_MODEL设置为2 (ThinkPHP框架的conf/convention.php)
4、把.htaccess文件放到入口文件的同级目录下
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
重启Apache之后,原来的
http:///index.php/Blog/read/id/1
就可以通过访问
http:///Blog/read/id/1
简化了URL地址。
Apache癿配置过程:
1、httpd.conf配置文件中加载了mod_rewrite.so模块(去掉前面的#号)
2、AllowOverride None 将None改为 All(注意有两处)
3、确保URL_MODEL设置为2 (ThinkPHP框架的conf/convention.php)
4、把.htaccess文件放到入口文件的同级目录下
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
重启Apache之后,原来的
http:///index.php/Blog/read/id/1
就可以通过访问
http:///Blog/read/id/1
简化了URL地址。
本文介绍如何通过URL重写技术去除URL中的index.php,以提高搜索引擎优化效果。具体步骤包括Apache配置、加载mod_rewrite模块、允许自定义.htaccess文件,并通过RewriteEngine和RewriteRule实现URL简化。

669

被折叠的 条评论
为什么被折叠?



