Apache 需要重写规则

Apache 需要重写规则,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我最近建立了自己的网页。现在我想使用RewriteRules来调用“www.exampleurl.de/events”,并让服务器显示“www.exampleurl.de/page/index.php?task=events”。将来会有更多的页面,因此需要一个动态规则 服务器结构如下所示: css core.css 形象 header.png navbar.jpg 页面 events.php home.php index.php .htaccess 我的.htaccess文件现在

我最近建立了自己的网页。现在我想使用RewriteRules来调用“www.exampleurl.de/events”,并让服务器显示“www.exampleurl.de/page/index.php?task=events”。将来会有更多的页面,因此需要一个动态规则

服务器结构如下所示:

  • css
    • core.css
  • 形象
    • header.png
    • navbar.jpg
  • 页面
    • events.php
    • home.php
    • index.php
  • .htaccess
我的.htaccess文件现在看起来如下所示:

<IfModule mo_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteRule ^(.*)$ page/index.php?task=$1 [L]
</IfModule>

重新启动发动机
重写基/
重写规则^(.*)$page/index.php?任务=$1[L]
我希望你能帮助我!谢谢

您可以使用:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^([^/]*)/?$ page/index.php?task=$1 [L]
</IfModule>

重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^([^/]*)/?$page/index.php?任务=$1[L]