我在这些地点有几个网页:
Home Page / Index : www.codeliger.com/index.php?page=home
Education : www.codeliger.com/index.php?page=home&filter=1
Skills: www.codeliger.com/index.php?page=home&filter=2
Projects: www.codeliger.com/index.php?page=home&filter=3
Work Experience: www.codeliger.com/index.php?page=home&filter=4
Contact : www.codeliger.com/index.php?page=contact我试图把它们改写成更漂亮的urls:
codeliger.com/home
codeliger.com/education
codeliger.com/skills
codeliger.com/projects
codeliger.com/experience
codeliger.com/contact我已经确认我的htaccess文件和mod重写工作到谷歌,但我不能让我的语法工作,在多个教程在线指定。
RewriteEngine on
RewriteRule /home /index.php?page=home
RewriteRule /([a-Z]+) /index.php?page=$1
RewriteRule /education /index.php?page=home&filter=1
RewriteRule /skills /index.php?page=home&filter=2
RewriteRule /projects /index.php?page=home&filter=3
RewriteRule /experience /index.php?page=home&filter=4我如何修改我的语法,将这些页面重写为更漂亮的urls?
发布于 2013-12-18 01:25:36
您应该做的第一件事是修复正则表达式。您不能拥有像[a-Z]这样的范围,您只需执行[a-z]并使用[NC] (无情况)标志。而且,您希望在规则的末尾,因为它将匹配对/projects的请求,这将使其更低的规则将永远不会被应用。然后,你想要摆脱你所有的领先的斜线。最后,您需要正则表达式的边界,否则它将匹配index.php并导致另一个错误。
所以:
RewriteEngine on
RewriteRule ^home /index.php?page=home
RewriteRule ^education /index.php?page=home&filter=1
RewriteRule ^skills /index.php?page=home&filter=2
RewriteRule ^projects /index.php?page=home&filter=3
RewriteRule ^experience /index.php?page=home&filter=4
RewriteRule ^([a-z]+)$ /index.php?page=$1 [NC]https://stackoverflow.com/questions/20646932
复制相似问题