.htaccess php html,.htaccess重定向.php和.html请求

我使用名为SilverStripe的框架…我们目前正在将旧网站迁移到此框架上.问题是旧站点URL以.php或.html结尾,而在新站点中则没有.

我需要修改第二个重写规则,以便将请求泵送到main.php而不使用任何.html或.php扩展名.

在我目前的.htaccess中,我有以下规则:

# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4

DirectoryIndex disabled

SetEnv HTTP_MOD_REWRITE On

RewriteEngine On

# 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 silverstripe-cache(/|$) - [F,L,NC]

RewriteRule composer\.(json|lock) - [F,L,NC]

# Process through SilverStripe if no file with the requested name exists.

# Pass through the original path as a query parameter, and retain the existing parameters.

RewriteCond %{REQUEST_URI} ^(.*)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule .* framework/main.php?url=%1 [QSA]

# If framework isn't in a subdirectory, rewrite to installer

RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule . %1/install.php? [R,L]

可能的解决方案(仍在测试):

RewriteCond %{REQUEST_URI} ^(.*)\.html [OR]

RewriteCond %{REQUEST_URI} ^(.*)\.php [OR]

RewriteCond %{REQUEST_URI} ^(.*)$

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule .* framework/main.php?url=%1 [QSA]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值