簡體   English   中英

.htaccess directoryIndex用於重定向不起作用

[英].htaccess directoryIndex for redirection not working

我有此代碼,但未按預期工作。

我需要做的是將DirectoryIndex與像這樣的參數一起使用

DirectoryIndex /index.php/english/login/

而且它不起作用,但是如果我用了這個

DirectoryIndex /index.php?language=english&module=login

有用。 由於網址的緣故,我需要使用反斜杠,因此當用戶訪問我的索引文件時,應使用參數將其重定向到默認網址。

例如

如果用戶訪問http://xxx.xxx.xxx.xxx/ ,則應自動將其重定向到此URL http://xxx.xxx.xxx.xxx/english/login/

# Rewrite Rules
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?language=$1&module=$2 [L,QSA]

# Declare Environments
SetEnvIf Request_URI "^.*" default_url=//xxx.xxx.xxx.xxx/english/login/

# Default Landing Page
DirectoryIndex /index.php/english/login/

# Error Redirection
# Error 403 - Forbidden
ErrorDocument 403 http:%{ENV:default_url}
# Error 404 - Not Found
ErrorDocument 404 http:%{ENV:default_url}

# Prevent Directory Listing
Options -Indexes

# Protect Files
<Files configuration.ini>
    Order allow,deny
    Deny from all
</Files>

你這樣嘗試過嗎?

RewriteRule ^home/([^-]+)/([^/]+)/?$ index.php?language=$1&module=$2 [L,NC]

暫無
暫無

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

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