2011-02-27 37 views
0

我知道如何重寫網址以重定向到頁面。在網址上重寫添加「/」

當「/」是不是在www.DomainName.com/user/myUserName結束重定向的工作原理:

RewriteRule /$ /user/index.php 

當我寫RewriteBase /上述規則不起作用,但404錯誤。

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

這可以被寫入的.htaccess或httpd.conf文件

+1

您是否可以編輯您的文章以包含'.htaccess'的當前內容? –

+0

@timcooper完成 – X10nD

+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> 
+0

我是重寫中的新手,那麼在你的答案中哪些部分會對我的問題提供必要的答案反映 – X10nD

+0

那麼你能給我一個完整的代碼示例嗎?它會很容易幫助你。 – glg