views:

53

answers:

4

Hi I have PHP oscommerce website, in which I have used htaccess for url rewriting to hide file names, now the problem i am facing is that my local server cannot replicate the htaccess as it should be doing, It is working perfect in live site..

Can some suggest what could be the reason?

EDITED

Below Is the htaccess rewrite rule i am using, i have replaced my original sites name with "mydomain" for security purpose:

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]

Now the problem goes like this:

I have a link which is like:

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

Now in local machine when i click this link I am navigated to url

http://192.168.1.55/about_us.html

rather it should be navigated to

http://192.168.1.55/mydomain/about_us.html

expected url is available on live server according to its domain name, but on local I get Page not found..

Please help

A: 

what you are using in local xampp, wamp or any other , you may need to enable htaccess

i m considering u are using xampp or recommend to use it.

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
JapanPro
Thanks for reply @japanPro but i have htaccess enables in my WAMP, what i miss in my pages is main folder name in url, like wise i must get url as http://myip/mydomain/index.html, but i get it as http://myip/index.html
OM The Eternity
A: 

Depending on the AccessFileName setting, your local Apache installation might use another name, for example _htaccess. Furthermore, make sure that the AllowOverride directive is not set to None.

Further documentation can be found in the .htaccess tutorial.

demonkoryu
+3  A: 

Your comment to JapanPro's answer suggests to me that your site is indeed in a subdirectory on your local server, in which case the likely reason that it doesn't work correctly (based on this and your other question) is because URL structure is different than your live server (it lives at the root there, but not in your local environment).

To fix this, you need to configure Apache to use a name-based virtual host, then add an entry in your hosts file that corresponds to the name you chose. Then you will use that domain name to access your site, and because the URL structure will be consistent with your live site, it should work correctly.

Example:

C:\Windows\System32\drivers\etc\hosts

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>

Edit: Here's a more in-depth description of setting up virtual hosts and editing in a new host entry that should hopefully explain this process better than I have.

Tim Stone
Thanks @Tim but can u explain ur second paragraph in more simpler way and similar folder structure as wamp and live server use to have...?
OM The Eternity
@OM The Eternity - I will try to explain in more detail, but right now I have some work to take care of, so it'll have to wait until I get back.
Tim Stone
A: 

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

If the host is [starts with (^)] mydomain.com,

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

rewrite it to http ://www.mydomain.com/$1

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

If the host is not(!) mydomain.com,

The Edifier