regex - Silverstripe 4.7.3 htaccess 重定向问题
问题描述
也许有人在这里使用 silverstripe 4.7.3 可以帮助我。
我对一种解决方案有疑问。我需要在不同的 URL 地址显示某个页面,例如:
test?code=1234 我使用 get 的代码从 db 下载一些记录,这个页面是在 cms 中创建的,到这个页面的链接是 /test。这个页面工作。
但现在我想在另一个 URL 上显示这个页面,应该是这样的:/test-1234/
RewriteRule ^test-(\d{4})/(([\sąćęłńóśźżĄĆĘŁŃÓŚŹŻa-zA-Z0-9_-])*)(\/)? /test/?code=$1&code=$2&%{QUERY_STRING} [L]
我发现 htaccess 中的这条规则没有得到满足,但我检查了标志 R=301 并且这条规则有效,有人可以解释为什么没有 R=301 的规则只有 [L] 不适用于原始 htaccess 吗?我包括完整的文件
<Files web.config>
Require all denied
</Files>
# Deny access to YAML configuration files which might include sensitive information
<Files ~ "\.ya?ml$">
Require all denied
</Files>
# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
#ErrorDocument 503 /assets/error-503.html
<IfModule mod_rewrite.c>
# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
<IfModule mod_dir.c>
DirectoryIndex disabled
DirectorySlash On
</IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteRule ^test-(\d{4})/(([\sąćęłńóśźżĄĆĘŁŃÓŚŹŻa-zA-Z0-9_-])*)(\/)? /test/?code=$1&code=$2&%{QUERY_STRING} [L]
# Process through SilverStripe if no file with the requested name exists.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
# Enable HTTP Basic authentication workaround for PHP running in CGI mode
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Deny access to potentially sensitive files and folders
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule ^\.env - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
RewriteRule (error|silverstripe|debug)\.log - [F,L,NC]
</IfModule>
### SILVERSTRIPE END ### ```
解决方案
推荐阅读
- business-process-management - 激活快照以启动 BPM 8.6 流程
- c++ - 成员函数如何理解对象是通过取消引用 const 指针获得的?
- fullcalendar - FullCalendar 可以在离线环境中使用吗
- python - Python JVM 烧瓶
- mysql - 是否可以将表链接到使用外键链接回第一个表的表?
- iis - 授权不适用于 IIS 中的 Windows 身份验证
- python - 提高二元分类模型的准确性
- android - 为什么recyclerview设计在不同的行android中显示不同的视图对齐方式?
- gson - 使用gson在spring rest中设置日期格式输出
- python - 使用 pandas read_excel 从标准输入读取