如何删除在URL [的.htaccess]字“索引”? [英] How to remove the word 'index' in the url [.htaccess]?
问题描述
目前,我使用的是下面的code,除去我的网址字索引 - 然而,问题是,它允许两个版本:一个没有,一个与[词] - 因此,我已引用了一个没有(在HTML) - 但用户仍然可以键入一个与字
我怎样才能完全从索引页擦字索引: http://example.com/index [html的]
进入 http://example.com/index
,但真的应该去的http //:example.com
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则(。*)/指数$ $ 1 / [R = 301]
的RewriteCond%{REQUEST_URI} / $
重写规则(。*)/ $ 1 [R = 301]
您可以使用:
RewriteEngine叙述上
的RewriteCond%{} THE_REQUEST /指数[NC]
重写规则^指数(*?)?(?:\ HTML)/ $ 1 [L,R = 301,NC]
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则(。*)/指数$ $ 1 / [R = 301,L,NC]
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。+?)/ $ $ 1 [R = 301,L]
Currently, I am using the below code to remove the word 'index' in my urls - however, the issue is that it allows for two versions: one without and one with [the word] - hence, I have referenced the one without (in the HTML) - but the user still might type the one with the word.
How can I completely wipe the word 'index' from the index page:http://example.com/index[.html]
goes to http://example.com/index
but should really go to http//:example.com
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/index$ $1/ [R=301]
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
You can use:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index [NC]
RewriteRule ^(.*?)index(?:\.html)?$ /$1 [L,R=301,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/index$ $1/ [R=301,L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ $1 [R=301,L]
这篇关于如何删除在URL [的.htaccess]字“索引”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!