.htaccess 当有人访问我的网站时,如何摆脱only/home?

.htaccess 当有人访问我的网站时,如何摆脱only/home?,.htaccess,redirect,.htaccess,Redirect,有人能帮我一下htaccess吗 当前,当有人访问我的网站somesite.com时,默认情况下,url看起来像somesite.com/home 我希望它只为主页不显示/主页,而只显示 这是我的整个htaccess文件 # Case 1 # -------------------------------------------------------# RewriteEngine On DirectoryIndex index.html index.php RewriteCond %{HTTP

有人能帮我一下htaccess吗

当前,当有人访问我的网站somesite.com时,默认情况下,url看起来像somesite.com/home

我希望它只为主页不显示/主页,而只显示

这是我的整个htaccess文件

# Case 1
# -------------------------------------------------------#
RewriteEngine On
DirectoryIndex index.html index.php
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
# -------------------------------------------------------#  

# Case 2
# -------------------------------------------------------#
# RewriteEngine on
# ExpiresActive On
# ExpiresDefault A2592000
# RewriteCond %{SERVER_PORT} 80
# RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# RewriteCond $1 !^(index\.php|images|public|assets|uploads|themes|install|backups|updates|asset|mob|robots\.txt|curl.php)
# RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
# -------------------------------------------------------#

# Case 3
# -------------------------------------------------------#
# <IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteCond %{REQUEST_URI} ^system.*
# RewriteRule ^(.*)$ index.php?/$1 [L]
# RewriteCond %{REQUEST_URI} ^application.*
# RewriteRule ^(.*)$ index.php?/$1 [L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ index.php?/$1 [L]
# </IfModule>
# -------------------------------------------------------#

# Case 4
# -------------------------------------------------------#
# RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ index.php/$1 [L]
# -------------------------------------------------------#

# Case 6 for SSL Hosting
# -------------------------------------------------------#
# RewriteEngine on
# ExpiresActive On
# ExpiresDefault A2592000
# RewriteCond %{SERVER_PORT} 80
# RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# RewriteCond $1 !^(index\.php|images|public|assets|uploads|themes|install|updates|asset|mob|robots\.txt)
# RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
# -------------------------------------------------------#

# case 5
# -------------------------------------------------------#
#RewriteEngine On
#DirectoryIndex index.html index.php
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule (.*) index.php/$1
# -------------------------------------------------------#

# secure GIT files
RedirectMatch 404 /\.git

<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
 Header set Cache-Control "max-age=604800, public"
</FilesMatch>

## EXPIRES CACHING ##
 <IfModule mod_expires.c>
 ExpiresActive On
 ExpiresByType image/jpg "access 1 year"
 ExpiresByType image/jpeg "access 1 year"
 ExpiresByType image/gif "access 1 year"
 ExpiresByType image/png "access 1 year"
 ExpiresByType text/css "access 1 month"
 ExpiresByType application/pdf "access 1 month"
 ExpiresByType text/x-javascript "access 1 month"
 ExpiresByType application/x-shockwave-flash "access 1 month"
 ExpiresByType image/x-icon "access 1 year"
 ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##

<ifModule mod_gzip.c>
 mod_gzip_on Yes
 mod_gzip_dechunk Yes
 mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
 mod_gzip_item_include handler ^cgi-script$
 mod_gzip_item_include mime ^text/.*
 mod_gzip_item_include mime ^application/x-javascript.*
 mod_gzip_item_exclude mime ^image/.*
 mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
#案例1
# -------------------------------------------------------#
重新启动发动机
DirectoryIndex.html index.php
重写cond%{HTTPS}=在…上
重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]
# -------------------------------------------------------#  
#案例2
# -------------------------------------------------------#
#重新启动发动机
#过期于
#到期默认A2592000
#重写cond%{SERVER_PORT}80
#重写规则^.*$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
#1美元^(索引\.php |图像|公共|资产|上传|主题|安装|备份|更新|资产| mob | robots\.txt | curl.php)
#重写规则^(.*)$index.php?/$1[QSA,L]
# -------------------------------------------------------#
#案例3
# -------------------------------------------------------#
# 
#重新启动发动机
#重写COND%{REQUEST_URI}^系统*
#重写规则^(.*)$index.php?/$1[L]
#重写cond%{REQUEST_URI}^应用程序*
#重写规则^(.*)$index.php?/$1[L]
#重写cond%{REQUEST_FILENAME}-F
#重写cond%{REQUEST_FILENAME}-D
#重写规则^(.*)$index.php?/$1[L]
# 
# -------------------------------------------------------#
#案例4
# -------------------------------------------------------#
#重新启动发动机
#重写cond%{REQUEST_FILENAME}-F
#重写cond%{REQUEST_FILENAME}-D
#重写规则^(.*)$index.php/$1[L]
# -------------------------------------------------------#
#SSL托管的案例6
# -------------------------------------------------------#
#重新启动发动机
#过期于
#到期默认A2592000
#重写cond%{SERVER_PORT}80
#重写规则^.*$https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
#1美元^(索引\.php | image | public |资产|上传|主题|安装|更新|资产| mob | robots\.txt)
#重写规则^(.*)$index.php?/$1[QSA,L]
# -------------------------------------------------------#
#案例5
# -------------------------------------------------------#
#重新启动发动机
#DirectoryIndex.html index.php
#重写cond%{REQUEST_FILENAME}-F
#重写cond%{REQUEST_FILENAME}-D
#重写规则(.*)index.php/$1
# -------------------------------------------------------#
#保护GIT文件
重定向匹配404/\.git
标题集缓存控制“最大年龄=604800,公共”
##过期缓存##
过期于
过期按类型映像/jpg“访问1年”
过期按类型图像/jpeg“访问1年”
ExpiresByType image/gif“访问1年”
过期按类型图像/png“访问1年”
ExpiresByType文本/css“访问1个月”
过期按类型应用程序/pdf“访问1个月”
ExpiresByType文本/x-javascript“访问1个月”
过期按类型应用程序/x-shockwave-flash“访问1个月”
过期按类型图像/x图标“访问1年”
ExpiresDefault“访问2天”
##过期缓存##
mod_gzip_on Yes
是的
mod|gzip|item|u include file.(html?| txt | css | js | php | pl)$
mod_gzip_item_包含处理程序^cgi脚本$
mod_gzip_项目包括mime^text/*
mod_gzip_item_包括mime^application/x-javascript*
mod_gzip_项_排除mime^image/*
mod_gzip_item_排除rspheader^内容编码:.*gzip*

请尝试以下内容,请确保在测试这些URL之前清除浏览器缓存

RewriteEngine ON
RewriteCond %{REQUEST_URI} !^/?$
RewriteRule ^ http://%{HTTP_HOST} [R=302,L]

R=302
是临时重定向,若要使其成为永久重定向,请使用上面的
R=301

您只需将此规则添加到.htaccess的顶部,就在
RewriteEngine下方的
行上:

重新编写引擎打开
重写规则^home/?$/[R=301,L,NC]
#剩下的规则就在下面

感谢您的努力,为了更好地理解,请您在问题中发布您想重定向/重写的url。@RavinderSingh13仅主页我不想显示/home-rest页面,如site.com/contact或site.com/about-us,仅主页index.php我不想要site.com应保持不变/home@RavinderSingh13我试着添加一个线,但网站不断刷新。我无法在这里发布。发布时,我收到了太多不允许的代码。我需要从当前htaccess中删除任何行吗?它会不断刷新website@Eveline,我认为您唯一的重写规则是针对
index.php
一个针对不存在的目录或文件的规则,可能您可以尝试将此规则放在后面,但老实说,我只测试了这些规则,效果很好。