2010-09-01 82 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,

相关问题