2014-07-25 20 views
0
SecFilterEngine Off 
    DirectorySlash Off 
    Options -Indexes 

    ErrorDocument 404 /not-found.php 
    ErrorDocument 403 /not-found.php 

    RewriteEngine On 
    RewriteBase/

    RewriteCond %{HTTP_HOST} ^xyz.com.au$ [NC] 
    RewriteRule ^(.*)$ http://someurl.au/$1 [R=301,L] 

    # RewriteCond %{QUERY_STRING} ^.+$ 
    # RewriteRule ^$ ? [R=301,L] 

    RewriteRule ^news_and_events.asp news-and-views? [NC,R=301,L] 
    RewriteRule ^detailapplication.asp products/applications? [NC,R=301,L] 
    RewriteRule ^detailproduct.asp products/products? [NC,R=301,L] 
    RewriteRule ^detailproduct.asp products/products? [NC,R=301,L] 
    RewriteRule ^products.asp products/products? [NC,R=301,L] 

此代碼在服務器上正常工作,但它不在localhost上工作。請有人告訴我必要的改變。在那個網址是我認爲需要在該網址作爲本地主機的變化,我有添加本地主機那裏,但仍然無法正常工作,請告訴我的問題如何在本地主機上運行htaccess重寫代碼

+1

也許你沒有所有的Apache mods加載使用''SecFilterEngine''甚至''ModRewrite''?如果你告訴我們什麼不工作,這將是好的例如。你得到一個''內部服務器錯誤''或只是''RewriteRules''不工作... – ins0

+0

服務器錯誤!錯誤沒有500 –

+0

看我的第一個評論 – ins0

回答

0

如果您的項目使用不同的文件夾,在RewriteBase中添加文件夾名稱下面。

RewriteBase /YOUR_PROJECT_FOLDER/ 

也刪除以下行。本地主機不需要。

RewriteCond %{HTTP_HOST} ^xyz.com.au$ [NC] 
RewriteRule ^(.*)$ http://someurl.au/$1 [R=301,L] 
+0

需要配置本地主機 –

0

我建議打開重寫日誌,以便您可以看到實際發生的情況。

我不知道你使用的是什麼版本的Apache,甚至操作系統,所以嘗試在.htaccess文件

添加以下內容到httpd.conf文件或該網站的虛擬主機定義,但不對於Apache 2.2 rewrite log Doc這樣

RewriteEngine On 
RewriteLog "full/path/to/rewrite.log" 
RewriteLogLevel 3 

如果您使用的是Apache 2.4 rewrite log Doc語法已更改爲這樣的事情

RewriteEngin On 
RewriteLog "full/path/to/rewrite.log" 
LogLevel alert rewrite:trace6 
0

首先嚐試刪除SecFilterEngine Off,因爲它需要默認情況下未安裝的mod_security。

如果仍然無法檢查您的httpd.conf。 mod_rewrite需要被激活。 See this answer.

如果它仍然不起作用,可能AllowOverride設置爲無。