簡體   English   中英

將根目錄重寫為子目錄

[英]Rewrite root directory to subdirectory

我正在開發一個運行后端和兩個不同目錄前端的網站。

  • /前端/
  • /管理/

我想運行/ frontend /作為root,同時仍然運行/ admin /作為它自己的目錄。

我需要寫入.htaccess才能執行此操作。

這就是我的.htaccess文件當前的樣子:

# Set the default handler.
DirectoryIndex index.php

# Prevent directory listing
Options -Indexes

<IfModule mod_rewrite.c>
    RewriteEngine On
    ErrorDocument 404 /admin/404.php
</IfModule>

任何和所有答案將不勝感激。

RewriteEngine On之后添加:

# Redirect any requests within frontend/, removing frontend/
RewriteRule ^frontend/(.*)$ http://www.example.com/$1 [R=301,L]
# Rewrite anything that is not in admin/ to frontend/
RewriteCond %{REQUEST_URI} !^/admin/
RewriteRule ^(.*)$ frontend/$1 [L]

請務必更新第2行的基本網站網址。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM