2013-08-02 60 views
0

重寫url RewriteRule^about//about.php [L,R = 301],但頁面也可以直接通過/about.php訪問。使用.htaccess重定向錯誤

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+about\.php\s [NC] 
RewriteRule^/about/ [R=302,L] 

RewriteRule ^about/?$ /about.php [L,NC] 

回答

0

使用此代碼替換代碼幫助工具,您可以輕鬆地爲.htaccess創建重定向代碼。

0

您可以使用規則來隱藏重定向:

#use [L] to hidden [R] to shown redirect 
RewriteRule ^(about|faq|home)/?$ $1.php [L] 

#to prevent access from about.php simply do this: 
RewriteRule (.+)\.php$ $1/ [R=301] 
#you need to know 301 redirect will be cached with browser for long time 
#so if you change rule - will be no effect for some visitors