【问题标题】:htaccess root/subfolder and root/subfolder/ into root/subfolder2/subfolder/htaccess 根/子文件夹和根/子文件夹/进入根/子文件夹2/子文件夹/
【发布时间】:2011-06-09 05:21:24
【问题描述】:

我希望能够在 URL 中输入以下内容:

https://mydomain.com/fork 或者 https://mydomain.com/fork/

两个都转到一个名为

的子文件夹

https://mydomain.com/prod/fork_contents/index.html

但仍然只显示https://mydomain.com/fork(或https://mydomain.com/fork/,无论哪种方式)

我希望 index.html 充当根目录,以便所有图像 url 等仍然有效(它们相对于 '/prod/fork_contents/')

目前根目录下的.htaccess是:

ErrorDocument 404 /live/site_documents/document404.html
ErrorDocument 403 /live/site_documents/accessDenied.html


Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} ^/$

RewriteRule ^fork$ /fork/index.html [L,QSA]
RewriteRule ^fork/$ /fork/index.html [L,QSA]

RewriteRule ^fork/(.*)$ /prod/forklift_contents/$1 [L,QSA]

想法?

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    您可以将问号用于可选章程

    RewriteRule ^fork\/? /prod/fork/$1 [L]
    

    有关重写的非常好的教程,请查看此网站 .htaccess tips and tricks..

    【讨论】:

      猜你喜欢
      • 2021-11-20
      • 2015-10-06
      • 1970-01-01
      • 2016-10-29
      • 2012-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多