首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从wordpress中删除尾部斜杠

从wordpress中删除尾部斜杠
EN

Stack Overflow用户
提问于 2020-02-19 02:09:38
回答 1查看 81关注 0票数 1

我的网址是

https://lofty-tibiabot.com/new/此网站在子文件夹中-新建

我想要地址是

https://lofty-tibiabot.com/new

代码语言:javascript
复制
  # BEGIN WordPress
    # The directives (lines) between `BEGIN WordPress` and `END WordPress` are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /new/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /new/index.php [L]
    </IfModule>
    # END WordPress

该怎么办呢?

EN

回答 1

Stack Overflow用户

发布于 2020-02-19 10:03:35

真的吗?

它变得有点混乱,因为Apache需要目录上的尾部斜杠来计算DirectoryIndex等。通过禁用尾部斜杠,我们必须使用mod_rewrite手动处理这种情况。

尝试以下操作:

1)/new/.htaccess文件移动到/.htaccess的根目录中。这使.htaccess脱离了WordPress,因此WP无法再维护此文件(这不一定是件坏事)。

2)/.htaccess文件更改为:

代码语言:javascript
复制
# Prevent mod_dir from appending the trailing slash to directories (with a 301 redirect)
DirectorySlash Off

RewriteEngine On
RewriteBase /new

# Allow mod_rewrite to match directories that do not have a trailing slash (when DirecrorySlash Off)
RewriteOptions AllowNoSlash

# Rewrite directory without trailing slash directly to the front-controller
RewriteRule ^new$ index.php [L]

# Standard front-controller
RewriteRule ^new/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^new/. index.php [L]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60287055

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档