.htaccess子文件夹没有正确重定向-错误404

问题描述

我在服务器的根目录中有一个wordpress安装,我想在一个名为“ ospos”的新目录中使用“ opensourcepos”脚本 如果我尝试访问链接 www.mysite.it/ospos/ 我被重定向到 www.mysite.it/public 出现404错误

要访问ospos安装,我必须转到 www.mysite.it/ospos/public 只有这样,一切才能正常工作。

也许ospos文件夹.htaccess文件中有一些说明 无法正确重定向。

代码.htaccess wordpress / root

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

代码.htaccess根目录/ ospos

# redirect to public page
  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^public$
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
    RewriteRule "^(.*)$" "/public/" [R=301,L]
  </IfModule>

# disable directory browsing
# For security reasons,Option all cannot be overridden.
Options +ExecCGI +Includes +IncludesNOEXEC +SymLinksIfOwnerMatch -Indexes

# prevent folder listing
IndexIgnore *

# Apache 2.4
<IfModule authz_core_module>
  # secure htaccess file
  <Files .htaccess>
    Require all denied
  </Files>

  # prevent access to PHP error log
  <Files error_log>
    Require all denied
  </Files>

  # prevent access to LICENSE
  <Files LICENSE>
    Require all denied
  </Files>

  # prevent access to csv,txt and md files
  <FilesMatch "\.(csv|txt|md|yml|json|lock)$">
    Require all denied
  </FilesMatch>
</IfModule>

# Apache 2.2
<IfModule !authz_core_module>
  # secure htaccess file
  <Files .htaccess>
    Order allow,deny
    Deny from all
    Satisfy all
  </Files>

  # prevent access to PHP error log
  <Files error_log>
    Order allow,deny
    Deny from all
    Satisfy all
  </Files>

  # prevent access to LICENSE
  <Files LICENSE>
    Order allow,deny
    Deny from all
    Satisfy all
  </Files>

  # prevent access to csv,txt and md files
  <FilesMatch "\.(csv|txt|md|yml|json|lock)$">
    Order allow,deny
    Deny from all
    Satisfy all
  </FilesMatch>
</IfModule>

代码.htaccess根目录/ ospos / public

RewriteEngine On

# To redirect a subdomain to a subdir because of https not supporting wildcards
# replace values between <> with your ones
# RewriteCond %{HTTP_HOST} ^<OSPOS subdomain>\.<my web domain>\.com$ [OR]
# RewriteCond %{HTTP_HOST} ^www\.<OSPOS subdomain>\.<my web domain>\.com$
# RewriteRule ^/?$ "https\:\/\/www\.<my web domain>\.com\/<OSPOS path>" [R=301,L]

# To rewrite "domain.com -> www.domain.com" uncomment the following lines.
# RewriteCond %{HTTPS} !=on
# RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
# RewriteCond %{HTTP_HOST} (.+)$ [NC]
# RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# if in web root
# RewriteRule ^(.*)$ index.php?/$1 [L]

# if in subdir comment above line,uncomment below one and replace <OSPOS path> with your path
RewriteRule ^(.*)$ /ospos/public/index.php?/$1 [L]

# disable directory browsing
# For security reasons,Option all cannot be overridden.
#Options All -Indexes
Options +ExecCGI +Includes +IncludesNOEXEC +SymLinksIfOwnerMatch -Indexes

# prevent folder listing
IndexIgnore *

# Apache 2.4
<IfModule authz_core_module>
  # secure htaccess file
  <Files .htaccess>
    Require all denied
  </Files>
  # prevent access to PHP error log
  <Files error_log>
    Require all denied
  </Files>
</IfModule>

# Apache 2.2
<IfModule !authz_core_module>
  # secure htaccess file
  <Files .htaccess>
    Order allow,deny
    Deny from all
    Satisfy all
  </Files>
  # prevent access to PHP error log
  <Files error_log>
    Order allow,deny
    Deny from all
    Satisfy all
  </Files>
</IfModule>

<IfModule mod_expires.c>
  <FilesMatch "\.(jpe?g|png|gif|js|css)$">
    ExpiresActive On
    ExpiresDefault "access plus 1 week"
  </FilesMatch>
</IfModule>

我已经阅读了许多问题并进行了许多测试,但是我仍然无法弄清楚要正确地重定向的位置和内容。

有人对此有何建议? 谢谢

PHP版本:7.3.13 MySQL版本:5.6.44-86.0 操作系统和版本:CentOS 7 WebServer是:Apache 2.4

我应该如何编辑:

RewriteCond %{REQUEST_URI} !^public$   
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
RewriteRule "^(.*)$" "/public/" [R=301,L]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...