Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 使用LightSpeed对.htacces中的mod_重写进行故障排除_.htaccess_Mod Rewrite_Litespeed - Fatal编程技术网

.htaccess 使用LightSpeed对.htacces中的mod_重写进行故障排除

.htaccess 使用LightSpeed对.htacces中的mod_重写进行故障排除,.htaccess,mod-rewrite,litespeed,.htaccess,Mod Rewrite,Litespeed,我有几个网页位于以下位置: 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&filt

我有几个网页位于以下位置:

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
我正在尝试将它们重写为更漂亮的URL:

codeliger.com/home
codeliger.com/education
codeliger.com/skills
codeliger.com/projects
codeliger.com/experience
codeliger.com/contact
我已经确认我的htaccess文件和mod rewrite对谷歌有效,但我无法使用多个在线教程中指定的语法

  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

如何修改语法以将这些页面重写为更漂亮的URL?

您可能要做的第一件事是修改正则表达式。您不能拥有像
[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]