Post by mmc013 » Wed Jan 24, 2018 8:52 am

Hi,
I recently created a copy of a live opencart website to my localhost for testing purposes. The way that I did this goes as follows
Tech:
-ubuntu 16.04
-apache 2.4
-lamp stack




1. Copied all files from live site to local drive
2. Exported a backup of live site through phpmyadmin
3. Copied all files to apache root directory
4. Changed configs for public_html/config.php and admin/config.php to reflect localhost and modified https to http
5. Changed config Database to a test name
6. Created new database with test name, imported database through phpmyadmin tools.
7. Disabled all htaccess files by renaming them .htaccess.txt
8. Now I currently have access to the localhost site. However, all the SEO urls are returning 404 errors.
9. Mod rewrite is on, but I believe that I have to modify my htaccess. files before I enable them as I'm on localhost.

Can someone advise me on how to gain access to these urls?
Thanks for any and all advice.

The following is a copy of my htaccess.txt at root directory
root/.htaccess.txt

Code: Select all

<IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
    <IfModule mod_setenvif.c>
        # 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

        # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
        # the above regex won't work. You can use the following
        # workaround to get the desired effect:
        BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

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

    <IfModule mod_headers.c>
        # Make sure proxies don't deliver the wrong content
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
</IfModule>
The following is a copy of my .htaccess at public html
public_html/.htaccess.txt

Code: Select all

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com
Header set Content-Security-Policy: upgrade-insecure-requests

RewriteEngine On
[highlight]RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301][/highlight]
Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|.twig|\.ini|\.log|(?<!robots)\.txt))">
 Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>


# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

[highlight]RewriteBase /[/highlight]
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/storage/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]





## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##


### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none

New member

Posts

Joined
Wed Jan 17, 2018 4:33 pm

Post by IP_CAM » Fri Jan 26, 2018 3:34 am

Well, your both ??? .htaccess files contain some crab like highlight
but I recall, that this has been mentioned in another reply some days ago already.

Code: Select all

RewriteEngine On
[highlight]RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301][/highlight]
---
[highlight]RewriteBase /[/highlight]
and I wonder, why and how you plan to have one of them in a ROOT, and on of them in a public_html
Section, you seem to miss something, somewhere ...

Ernie

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by mmc013 » Thu Feb 01, 2018 6:23 am

Yes, the highlight just happened to be a forum feature that is superseded by the code block feature.

Also, not entirely sure why the htaccess was set up like that since I'm not the dev who initially set up the shop, but I eventually got it all working out.

New member

Posts

Joined
Wed Jan 17, 2018 4:33 pm

Post by ckeilitz » Wed Jul 18, 2018 6:34 pm

Did you ever resolve your problem? I have the same issue after doing almost exactly what you did w/3.0.2.0...exported my production site to local machine, localhost. Everything works great, except SEO URLs getting 404. I tried several .htaccess files, the default and ones found on the internet.

My next troubleshooting step will have to probably be putting log statements into the /catalog/controller/startup/seo_url.php file or find out if I can get the webserver to dump mod_rewrite details to see if it is decomposing the URL properly.

Newbie

Posts

Joined
Thu Jan 25, 2018 2:21 am

Post by khnaz35 » Wed Oct 24, 2018 2:29 pm

IP_CAM wrote:
Fri Jan 26, 2018 3:34 am
Well, your both ??? .htaccess files contain some crab like highlight
but I recall, that this has been mentioned in another reply some days ago already.

Code: Select all

RewriteEngine On
[highlight]RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301][/highlight]
---
[highlight]RewriteBase /[/highlight]
and I wonder, why and how you plan to have one of them in a ROOT, and on of them in a public_html
Section, you seem to miss something, somewhere ...

Ernie

Hi Ernie i am also having same issue with OC 2.3.0.2, can you share one .htaccess to resolve this issue

Thanks
Ali

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by IP_CAM » Thu Oct 25, 2018 2:02 am

Well, I use the one enclosed at present, and it's sufficient, to so generate a good
overall result 8)
But it's NOT configured to HTTPS, as it comes, and it also contains links named
'ejacob\.ch', which need to be changed, if one of those RULES is activated.
It contains several RULES, so, just activate, what really is required, not all of them
can be used at once ... :laugh:
PS: Don't forget, to add the Shop Directory directly onto the RewriteBase/, Line,
like shop/ - store/ e.t.c., to make it link, if you use a Shop Subdirectory.
Samples: RewriteBase/shop/ - RewriteBase/store/ , e.t.c.
Good Luck ! ;)
Ernie
---
Image

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by khnaz35 » Fri Oct 26, 2018 12:40 pm

IP_CAM wrote:
Thu Oct 25, 2018 2:02 am
Well, I use the one enclosed at present, and it's sufficient, to so generate a good
overall result 8)
But it's NOT configured to HTTPS, as it comes, and it also contains links named
'ejacob\.ch', which need to be changed, if one of those RULES is activated.
It contains several RULES, so, just activate, what really is required, not all of them
can be used at once ... :laugh:
PS: Don't forget, to add the Shop Directory directly onto the RewriteBase/, Line,
like shop/ - store/ e.t.c., to make it link, if you use a Shop Subdirectory.
Samples: RewriteBase/shop/ - RewriteBase/store/ , e.t.c.
Good Luck ! ;)
Ernie
---
Image
Thanks for file sharing,
I disable seo url from system admin setting and its start working yeah i know i didn't put any .htaccess file in root directory on localhost either

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia
Who is online

Users browsing this forum: jagall, moreduff and 261 guests