重写网址以添加“/”

时间:2011-02-27 18:20:18

标签: .htaccess mod-rewrite url-rewriting rewrite

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

如果“/”不在www.DomainName.com/user/myUserName的末尾,则重定向有效:

RewriteRule /$ /user/index.php

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

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

这可以写入.htaccess或httpd.conf

1 个答案:

答案 0 :(得分: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>
相关问题