【问题标题】:htaccess change directoryhtaccess 更改目录
【发布时间】:2012-01-11 03:52:27
【问题描述】:

您好,我需要使用位于根文件夹中的现有 htaccess。 我现在需要创建一个新目录 /testfolder/ 成为 http://www.companydomain.com/testfolder/,所有根目录的文件都将位于该目录。

如何使用现有的 htaccess 实现这一点?非常感谢您提前提供的帮助!

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !(.*)/(.*).html$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]

# 301
RewriteCond %{HTTP_HOST} !^www\.companydomain\.com$ [NC]
RewriteRule .? http://www.companydomain.com%{REQUEST_URI} [R=301,L]
RewriteRule ^Sportsbooks\/(.*).html$ Sportsbooks\/$1\/ [R=301,L]

【问题讨论】:

    标签: .htaccess mod-rewrite directory


    【解决方案1】:

    .htaccess 文件会将http://example.com/file.html 重定向到http://example.com/folder1/file.html

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} example.com$ [NC]
    RewriteCond %{HTTP_HOST} !folder1
    RewriteRule ^(.*)$ http://example.com/folder1/$1 [R=301,L]
    

    我希望这会有所帮助!

    【讨论】:

    • 嗨,我有一个无限循环重定向
    猜你喜欢
    • 2012-09-26
    • 2017-06-06
    • 1970-01-01
    • 2011-03-11
    • 2011-08-24
    • 1970-01-01
    • 1970-01-01
    • 2021-01-29
    • 2013-05-15
    相关资源
    最近更新 更多