首页 文章

.htaccess文件重写

提问于
浏览
3

我有重写网址的问题 . 发生以下情况:

http://www.mysite.nl/scores
    http://www.mysite.nl/registreren
    http://www.mysite.nl/login

这些网址将被重定向到index.php?route = scores等

这一切都很好 . 但是现在我在像图像和样式表这样的子目录中有模板文件 . 这些文件在

  • template / css / style.css

  • images / images.png等

现在所有这些文件也被重定向到index.php?route .
我知道前导斜杠和文件的所有链接都是绝对路径 .

以下代码用于.htaccess文件 .

RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)/?$ index.php?route=$1 [L,QSA]

1 回答

  • 2

    尝试使用以下代码添加RewriteBase:

    RewriteBase /
    

    根据服务器配置, %{REQUEST_FILENAME} 可能在开头包含斜杠,这将产生绝对路径而不是相对路径 .

相关问题