PHP-如何使用mod_rewrite制作漂亮的网址 [英] PHP - How to make pretty urls using mod_rewrite
本文介绍了PHP-如何使用mod_rewrite制作漂亮的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何使我的URL变得漂亮且对SEO友好,并能与PHP代码一起使用.
I'm wondering how to make my URLs pretty and SEO friendly and also work with PHP code.
目前,一切正常(例如example.com/test/可以正常运行).
Currently everything works fine (for example example.com/test/ is fine and works).
但是,当我有error.php?id=404
时,我希望它转到/error/404/
.
However when I have error.php?id=404
, I want it to go to /error/404/
.
我该怎么做?
我当前的.htaccess是...
My current .htaccess is...
RewriteCond /%{REQUEST_FILENAME} !-d
RewriteCond /%{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php
请帮忙吗?
推荐答案
您可以选择让框架进行处理,也可以阅读有关mod_rewrite的更多信息
You can choose to let the framework handle it, or your can read more about mod_rewrite here
URL中的下划线不是SEO友好
the underscore in url is not SEO friendly
这篇关于PHP-如何使用mod_rewrite制作漂亮的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文