【问题标题】:.htaccess -> Domain parameter -> https://example.com/page is working and https://example.com/ not.htaccess -> 域参数 -> https://example.com/page 正在工作,而 https://example.com/ 没有
【发布时间】:2021-05-06 03:29:37
【问题描述】:
我的 .htaccess 文件有问题。我将随时添加带有当前域的参数。它适用于https://example.com/page,但不适用于https://example.com/
我当前的 .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?domain=%{HTTP_HOST}&page=$1 [L,QSA]
我已经尝试过 .* 和 .在 RewriteRule 而不是 ^(.*)$
【问题讨论】:
标签:
.htaccess
mod-rewrite
indexing
parameters
dns
【解决方案1】:
使用您显示的示例,只需添加检查 Uri 的条件,然后使用 index.php 提供它。请您尝试以下操作。请确保在测试您的 URL 之前清除您的浏览器缓存。
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?domain=%{HTTP_HOST}&page=$1 [L,QSA]
RewriteCond %{REQUEST_URI} ^/?$
RewriteRule ^ /index.php?domain=%{HTTP_HOST} [L]