2010-09-01 78 views
1

我有PHP oscommerce網站,其中我已經使用htaccess的URL重寫來隱藏文件名,現在我面臨的問題是,我的本地服務器無法複製htaccess,因爲它應該是這是在現場工作完美..本地和現場服務器htaccess規則不同

可以有人建議可能是什麼原因?

EDITED

下面是我使用htaccess的重寫規則,我已經取代了我原來的站點, 「MYDOMAIN」 爲安全起見名稱:

RewriteEngine On 

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

#INDEX PAGE 
#---------- 
RewriteRule http://www.mydomain.com/index\.html http://www.mydomain.com/ [R] 
RewriteRule http://www.mydomain.com/index\.php http://www.mydomain.com/ [R] 
RewriteRule ^index.html index.php [NC] 


#STATIC PAGES 
#------------ 
RewriteRule ^about-us.html information.php?info_id=1 [NC] 
RewriteRule ^faqs.html information.php?info_id=8 [NC] 
RewriteRule ^contact-us.html contact_us.php?info_id=9 [NC] 
RewriteRule ^terms-and-conditions.html information.php?info_id=10 [NC] 
RewriteRule ^privacy-policy.html information.php?info_id=3 [NC] 

#RewriteRule ^we-design-your-banner-free.html information.php?info_id=11 [NC] 
RewriteRule ^vinyl-banner-samples.html vinyl_banner_sample.php [NC] 
RewriteRule ^art-specifications.html art_specification.php [NC] 
RewriteRule ^sitemap.html sitemap.php [NC] 


#checkout - my account pages 
#--------------------------- 
#RewriteRule ^account.html account.php?$1 [NC] 
#RewriteRule ^checkout.html checkout.php?$1 [NC] 

現在的問題像這樣:

我有一個鏈接:

<a href="/about_us.html" title="About Us" class="footertext_link">About Us</a> 

現在,在本地機器上,當我點擊這個鏈接,我瀏覽到網址

http://192.168.1.55/about_us.html 

而應被導航到

http://192.168.1.55/mydomain/about_us.html 

預期URL根據可用活的服務器上的域名,但在本地我找不到網頁..

請幫忙

+4

在任何情況下都不會向我們顯示有問題的htaccess文件。這將需要所有的懸念 – 2010-09-01 09:44:30

+0

你真的只是問第三次你問過的同一個問題嗎? – 2010-09-01 11:07:56

+0

有人可以請教@TIM的回覆嗎? – 2010-09-01 13:13:14

回答

4

您對JapanPro's answer的評論向我建議,您的網站確實位於本地服務器的子目錄中,在這種情況下,其無法正常運行的可能原因(基於此和your other question)是因爲URL結構不同而不是您的實時服務器(它位於根目錄的根目錄,但不在本地環境中)。

要解決此問題,您需要將Apache配置爲use a name-based virtual host,然後在您的主機文件中添加一個與您選擇的名稱相對應的條目。然後,您將使用該域名訪問您的網站,並且由於該網址結構將與您的實時網站保持一致,因此應該可以正常運行。

實施例:

C:\ Windows \ System32下\驅動程序\等\主機

 
127.0.0.1 domain.local 

的httpd.conf

<VirtualHost *:80> 
    ServerName domain.local 

    DocumentRoot "C:\wampdir\htdocs\mydomain" 

    <Directory "C:\wampdir\htdocs\mydomain"> 
     Options Indexes FollowSymLinks Includes 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

編輯:設定Here's a more in-depth description啓動虛擬主機並在新主機中進行編輯應該希望能比我更好地解釋這個過程。

+0

謝謝@Tim,但你可以用更簡單的方式和類似的文件夾結構來解釋你的第二段,因爲wamp和live服務器使用...? – 2010-09-01 12:03:00

+0

@OM永恆 - 我會試着更詳細地解釋,但現在我有一些工作需要照顧,所以它必須等到我回來。 – 2010-09-01 12:10:35

0

你在本地的xampp,wamp或其他任何你使用的,你可能需要啓用htaccess

我考慮你正在使用xampp或推薦使用它。

How to enable or use .htaccess on Apache Web Servers in Windows: 

Using a text editor, open the httpd.conf file. In XAMPP, this file is found in the \apache\conf directory 
Locate the following line of code: 
#LoadModule rewrite_module modules/mod_rewrite.so 

Remove the # from the line as seen below to enable the module: 
LoadModule rewrite_module modules/mod_rewrite.so 

Save the httpd.conf file and Restart your server 
Restart your Apache Server 
+0

感謝您的回覆@japanPro,但我有我的WAMP htaccess啓用,我在我的網頁中想念的是主要的文件夾名稱在URL中,就像智者我必須得到的URL爲http://myip/mydomain/index.html,但我得到它作爲http://myip/index.html – 2010-09-01 09:51:36

0

RewriteCond %{HTTP_HOST} ^mydomain.com [NC]

如果主機是[開始(^)] mydomain.com,

RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301] 

重寫它爲http://www.mydomain.com/$1

RewriteCond %{HTTP_HOST} !mydomain.com [NC] 

如果主機不是(!)mydomain.com,

相關問題