更改DirectoryIndex后,403无法正常工作

小子钻石

我在.htaccess文件中禁用了目录浏览,最近我更改了默认的索引页,该页可以正常工作。但是现在当我浏览到:domain.com/images/时,应该给我一个403禁止的错误,但这只是进入索引页面' /en/index.php '本身。

#Turn rewrite engine on
RewriteEngine on

#Disable directory browsing
Options -Indexes

#Default index page
DirectoryIndex /en/index.php

ErrorDocument 404 /error.php

#Add trailing slash
RewriteCond %{REQUEST_URI} !\.[^./]+$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*) /$1/ [R=301,L]

#Remove trailing slash
RewriteCond %{REQUEST_URI} !^/en/$
RewriteCond %{REQUEST_URI} !^/fr/$
RewriteCond %{REQUEST_URI} !^/images/$
RewriteCond %{REQUEST_URI} !^/includes/$
RewriteCond %{REQUEST_URI} !^/stylesheets/$
RewriteRule ^/$ /$1 [R=301,L]

#Redirect non-www to www
RewriteCond %{HTTP_HOST}  \.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]

#Add trailing slash
RewriteCond %{REQUEST_URI} !\.[^./]+$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*) /$1/ [R=301,L]

#English
RewriteRule ^what-is-minecraft/$ /en/what-is-minecraft.php [NC,L]
RewriteRule ^getting-started/$ /en/getting-started.php [NC,L]
RewriteRule ^mods/$ /en/mods.php [NC,L]
RewriteRule ^best-mods/$ /en/best-mods.php [NC,L]
RewriteRule ^terms-of-service/$ terms-of-service.php [NC,L]
RewriteRule ^privacy-policy/$ privacy-policy.php [NC,L]

#French
RewriteRule ^fr/cest-quoi-minecraft/$ /fr/cest-quoi-minecraft.php [NC,L]
RewriteRule ^fr/demarrage/$ /fr/demarrage.php [NC,L]
RewriteRule ^fr/mods/$ /fr/mods.php [NC,L]
RewriteRule ^fr/meilleurs-mods/$ /fr/meilleurs-mods.php [NC,L]
RewriteRule ^fr/$ /fr/index.php [NC,L]

有人能找出问题所在吗?

编辑:张贴了我完整的.htaccess代码。

价格

使用此代码,您将不需要删除尾部斜杠,因为它不会被附加到php文件的重定向中,并且您不必担心存在的文件或文件夹,因为它们也不会被重写。

Options +FollowSymLinks -MultiViews -Indexes

RewriteEngine On
RewriteBase /

ErrorDocument 404 /error.php

#Redirect non-www to www
RewriteCond %{HTTP_HOST} \.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Remove the php extension
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=301,L]

# Does not end with trailing slash redirect
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^ %{REQUEST_URI}/ [R=301,L]

# To internally redirect /anything to /anything.php if /anything.php exists
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/en [NC]
RewriteCond %{DOCUMENT_ROOT}/en/$1\.php -f
RewriteRule ^(.+?)/?$ en/$1.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

更改文件后,Make无法正常工作

发布后的更改jQuery无法正常工作

更改系统日期后,Jenkins无法正常工作

更改网站网址后,网址重写无法正常工作

更改siteurl和主页后,WordPress网站无法正常工作

主机名更改后,mDNS(Avahi)无法正常工作

更改textview位置后,TextView上的动画无法正常工作

更改CookieDomain后,FormsAuthentication.SignOut()无法正常工作

更改系统时间后,QThread :: sleep无法正常工作

Python更改工作目录无法正常工作?

在移动设备上更改显示设置后,Youtube API无法正常工作

服务器上的IP更改后,Facebook登录无法正常工作

迁移网站后WordPress网站无法正常工作-更改了网站地址(URL)

vs代码调试在软件包名称更改后无法正常工作

在没有UI的情况下更改选择后,TreeView多项选择无法正常工作

Windows应用程序更改类型后,应用程序无法正常工作

更改区域后,Firebase云功能onCall无法正常工作

更改程序包名称后,Flutter App无法正常工作

将内容视图从垂直更改为水平后,Android Button事件无法正常工作

从1.4.2.REALESE更改为2.1.7.REALESE后,Springboot项目无法正常工作

在场景委托中更改主故事板后,Naviagtion Controller无法正常工作

看似无关的代码更改后,按键检测将无法正常工作

使用大小类更改约束后,模拟器无法正常工作

我更改.htaccess后,我的Css和Js无法正常工作

自从我更改了Web服务的URL后,我的应用程序无法正常工作

使用 jQuery 在 ajax 响应后更改输入值无法正常工作

403 Forbidden:将文档根文件夹移动到iCloud驱动器后,Apache无法正常工作

应用emptyText后,Tagfield无法正常工作

删除后,Cassandra UPDATE无法正常工作