.htaccess 正在尝试将/webhooks/index.php转换为/webhooks/index.php

chy5wohz  于 2022-11-16  发布在  PHP
关注(0)|答案(1)|浏览(169)

我正在尝试转换:

https://mywebsite.com/webhooks/agentcrm/contacts/index.php?id=V8vkUHkCN0dwBYvTVgKr

至:

https://mywebsite.com/webhooks/agentcrm/contacts/V8vkUHkCN0dwBYvTVgKr

我目前尝试的htaccess文件看起来像下面:

RewriteEngine On

RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}  [L,R=301]

RewriteRule /webhooks/agentcrm/contacts/(.*) /webhooks/agentcrm/contacts/index.php?id=$1 [L]

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
   php_flag display_errors Off
   php_value max_execution_time 1800
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 128M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
   php_value upload_max_filesize 128M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 1800
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 128M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
   php_value upload_max_filesize 128M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule mod_rewrite.c>
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

有人能帮忙找出问题吗?

soat7uwm

soat7uwm1#

使用显示示例和尝试,请尝试以下.htaccess规则文件请确保.htaccess位于根目录下同时在测试URL之前清除浏览器缓存

RewriteEngine On

RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}  [L,R=301]

RewriteRule /webhooks/agentcrm/contacts/(.*) /webhooks/agentcrm/contacts/index.php?id=$1 [L]

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
   php_flag display_errors Off
   php_value max_execution_time 1800
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 128M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
   php_value upload_max_filesize 128M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 1800
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 128M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
   php_value upload_max_filesize 128M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule mod_rewrite.c>
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    RewriteCond %{THE_REQUEST} \s/(webhooks/agentcrm/contacts)/index\.php\?id=(\S+)\s [NC]
    RewriteRule ^ /%1/%2? [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(webhooks/agentcrm/contacts)/([^/]*)/?$ $1/index.php?id=$2 [QSA,NC,L]
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

相关问题