首页 文章

重写网址以添加“/”

提问于
浏览
0

我知道如何重写网址以重定向到页面 .

当“/”不在www.DomainName.com/user/myUserName的末尾时,重定向工作:

RewriteRule /$ /user/index.php

当我写RewriteBase /上面的规则不起作用,但是404错误 .

如何在 www.DomainName.com/user/myUserName/ 末尾添加 "/" 并仍然重定向到 /user/index.php .

这可以写入.htaccess或httpd.conf

1 回答

  • 0

    嘿,这是我使用的默认html访问 .

    Options +FollowSymLinks +ExecCGI
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    # we skip all files with .something
    RewriteCond %{REQUEST_URI} \..+$
    RewriteCond %{REQUEST_URI} !\.html$
    RewriteRule .* - [L]
    
    # we check if the .html version is here (caching)
    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    
    # no, so we redirect to our front web controller
    RewriteRule ^(.*)$ index.php [QSA,L]
    </IfModule>
    

相关问题