2

I copy all files of my website for to run it on my PC, but when I want to see pages it doesn't work and show me the phpinfo(). I have .htaccess in root and this is the code of it but it doesn't work and I also can't see backend page!

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

Where is the problem?

  • Is your apache configured for site directory? AllowOverride All Order allow,deny allow from all – versedi May 30 '15 at 10:50
  • @versedi: I have configured http.conf correctly and I have directory tag like this: <Directory /> Options All AllowOverride All Order allow,deny allow from all </Directory> – Elham Gdz May 30 '15 at 11:19
  • You have to set that for subdirectories if your project is placed in subdir. – versedi May 30 '15 at 12:03
  • what is the url? If it is not http://localhost/index.php you need to change the RewriteBase – Fabian Blechschmidt May 30 '15 at 12:24
  • @FabianBlechschmidt: why i should change the RewriteBase? – Elham Gdz May 31 '15 at 6:39
1

This should be a comment, but please check the structure of your http.conf you pasted this into a comment:

<Directory />
    Options All 
    AllowOverride All 
    Order allow,deny allow from all 
</Directory>

I see a problem here: < Directory /> with the / in the opening directory tag, you should put the path to your files there, something like:

<VirtualHost *:80>
    DocumentRoot /var/www/html
    <Directory /var/www/html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>

Check here for more information:

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-magento-on-ubuntu-14-04

http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/installing_magento_ubuntu_9.04_server

http://httpd.apache.org/docs/current/sections.html

  • I add this <VirtualHost *:80> DocumentRoot D:/http/www/ <Directory D:/http/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All </Directory> </VirtualHost> in httpd.conf but nothing change!!! – Elham Gdz Jun 1 '15 at 5:57
  • which OS are you using? Did you enabled your vhost, if you are using xampp or something similar I think you have to uncomment one line in http.conf to enable vhosts, if you are using linux and apache2 then make sure that you run a2ensite yoursite.conf? Also could you paste the complete vhost and .htaccess. Also make sure you have the local.xml in place – lloiacono Jun 1 '15 at 7:16
  • I use it for localhost (windows) and using apache2. – Elham Gdz Jun 1 '15 at 7:39
1

Complete .htaccess to configure on local setup -

############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi

#    Action php5-cgi /cgi-bin/php5-cgi
#    AddHandler php5-cgi .php

############################################
## GoDaddy specific options

#   Options -MultiViews

## you might also need to add this line to php.ini
##     cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini

############################################
## this line is specific for 1and1 hosting

    #AddType x-mapp-php5 .php
    #AddHandler x-mapp-php5 .php

############################################
## default index file

    DirectoryIndex index.php



############################################
## adjust memory limit

#    php_value memory_limit 64M
    php_value memory_limit 768M
    php_value max_execution_time 18000

############################################
## disable automatic session start
## before autoload was initialized

    php_flag session.auto_start off

############################################
## enable resulting html compression

    #php_flag zlib.output_compression on

###########################################
## disable user agent verification to not break multiple image upload

    php_flag suhosin.session.cryptua off




###########################################
## disable POST processing to not break multiple image upload

    SecFilterEngine Off
    SecFilterScanPOST Off



############################################
## prevent clickjacking

    Header set X-Frame-Options SAMEORIGIN




############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip

    # Insert filter on all content
    ###SetOutputFilter DEFLATE
    # Insert filter on selected content types only
    #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

    # Netscape 4.x has some problems...
    #BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
    #BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
    #BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # Don't compress images
    #SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

    # Make sure proxies don't deliver the wrong content
    #Header append Vary User-Agent env=!dont-vary





############################################
## make HTTPS env vars available for CGI mode

    SSLOptions StdEnvVars





############################################
## enable rewrites

    Options +FollowSymLinks
    RewriteEngine on

############################################
## you can put here your magento root folder
## path relative to web root

    #RewriteBase /magento/

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]

############################################
## redirect for mobile user agents

    #RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
    #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
    #RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]




############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead

    AddDefaultCharset Off
    #AddDefaultCharset UTF-8



############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

    ExpiresDefault "access plus 1 year"



############################################
## By default allow all access

    Order allow,deny
    Allow from all

###########################################
## Deny access to release notes to prevent disclosure of the installed Magento version

    
        Order allow,deny
        Deny from all
    
############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags

    #FileETag none

1

It sounds as though you don't have the rewrite module enabled in apache. Can you make sure you have enabled it?

Open your http.conf and look for a bunch of LoadModule lines. Find the one with LoadModule rewrite_module modules/mod_rewrite.so and make sure it does not have a hash mark (#) in front of it. Then restart your apache instance for the changes to take effect.

Instructions based on: https://webdevdoor.com/php/mod_rewrite-windows-apache-url-rewriting

Not the answer you're looking for? Browse other questions tagged or ask your own question.