Post by markmarkus » Mon Jan 27, 2014 3:36 am

My problem only happens in localhost. For my online site everything works fine.

I have renamed the file correctly to .htaccess
I have enabled SEO Urls in the SETTINGS
I have given products etc seo keywords
I have enabled the modrewrite in my Apache server under Ubuntu

I have tried using RewriteBase /, also RewriteBase /mysite/, also RewriteBase /mysite, also RewriteBase /www/var/, also RewriteBase /www/var/mysite/ but nothing seems to work.

.htaccess is identical in my online and local site.

Any idea? ???

New member

Posts

Joined
Thu Dec 26, 2013 7:51 am

Post by butte » Mon Jan 27, 2014 11:57 am

Proofread it carefully -- if you got it working locally, then you just need to be sure where OC is on the server (from perspective of .htaccess). The .htaccess needs to be given a basedir, which will be either (a) the public or domain root (shown as /) or (b) the store's root in a directory (shown as /directory/ -- WITH the trailing /). That much can be the same on both machines. However, both / and /directory/ must reflect where OC actually is. Proofread it carefully. If OC is in the same position in or above the root, or instead above that in a directory, then how it is laid out, / or /directory/, should be the same. Bear in mind that on your local machine public_html/ or its equivalent may not be the same as on the public host, where, for example, you may have public_html/domainnamehosted/ as the effective root. Those two, for your .htaccess, are equivalent as /, provided that OC sits there. If OC sits above that, then that is where /directory/ starts. These are ordinarily equivalent: public_html/, www/, htdocs/, httpdocs/. They are publically accessible, and in terms of Apache are "aliases" for a publically accessible directory at a specific level in a host's directory structure. If OC is more than one step up from the root /, then its position is /directory/directory/directory/ or the like.

Guru Member

Posts

Joined
Wed Mar 20, 2013 6:58 am

Post by markmarkus » Sun Feb 09, 2014 8:42 pm

I still have the same problem:
SEO url in localhost get 404 error. Non SEO url are displaying ok tough.

My .htaccess is as follow:

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

 Options +FollowSymlinks

# Prevent Directoy listing 
 Options -Indexes

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
 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/ 

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /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]

### 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
I have renamed the file correctly to .htaccess
I have enabled SEO Urls in the SETTINGS
I have given products etc seo keywords
I have enabled the modrewrite in my Apache server under Ubuntu

Any idea of what could be wrong?

New member

Posts

Joined
Thu Dec 26, 2013 7:51 am

Post by markmarkus » Mon Feb 10, 2014 12:43 am

I finally solved it.

When using localhost you can see this proposed solution in many wesites:

1 Configure Apache mod_rewrite

Code: Select all

    a2enmod rewrite
2 add the following code to /etc/apache2/sites-available/default

Code: Select all

    AllowOverride All
3 Restart apache

Code: Select all

   /etc/init.d/apache2 restart
That didn't work for me. The trick was that in Apache 2.4 and Ubuntu 13.10 the Apache config files end with .conf extension. But besides /etc/apache2/sites-available/default.conf you also have another .conf file in /etc/apache2/sites-available/ which also has to be changed to AllowOverride All. When this is done the .htaccess file works perfectly.

I hope this helps other people with the same problem.

New member

Posts

Joined
Thu Dec 26, 2013 7:51 am

Post by mmc013 » Thu Jan 18, 2018 8:34 am

markmarkus wrote:
Mon Feb 10, 2014 12:43 am
I finally solved it.

When using localhost you can see this proposed solution in many wesites:

1 Configure Apache mod_rewrite

Code: Select all

    a2enmod rewrite
2 add the following code to /etc/apache2/sites-available/default

Code: Select all

    AllowOverride All
3 Restart apache

Code: Select all

   /etc/init.d/apache2 restart
That didn't work for me. The trick was that in Apache 2.4 and Ubuntu 13.10 the Apache config files end with .conf extension. But besides /etc/apache2/sites-available/default.conf you also have another .conf file in /etc/apache2/sites-available/ which also has to be changed to AllowOverride All. When this is done the .htaccess file works perfectly.

I hope this helps other people with the same problem.
I know this is a long shot based on the date of this post, but could I ask you what you ultimately set your rewrite base directory to?

New member

Posts

Joined
Wed Jan 17, 2018 4:33 pm

Post by villagedefrance » Mon Jan 22, 2018 6:30 pm

This is how it should look like:

## SEO URL Settings
RewriteEngine On

RewriteBase /www/11100/

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


My local server root is: Xampp/htdocs
so the Base becomes: Xampp/htdocs/www/11100/

I hope this helps.

OpenCart custom solutions @ https://villagedefrance.net


User avatar
Active Member

Posts

Joined
Wed Oct 13, 2010 10:35 pm
Location - UK

Post by mmc013 » Wed Jan 24, 2018 6:47 am

Hi Villagedefrance,

Thank you for taking the time to respond to this question. My setup is very similar to yours as I'm running off an apache lamp server. However I don't have a www directory in my in my server root. I'm asking these questions because I wanted to run a localhost copy of a live opencart website with full functionality so I could test additions and modifications in a controlled environment, but simply changing the configs and importing the database left me with a functional home index, 404 urls, and an unable to connect message at main shop.

my local server root is modified to
home/root/
After looking at your rewrite base, and looking at my directories, it doesn't appear that I have a WWW folder in those locations. Its apparent to me that I have a weak grasp of exactly how rewrite bases work. In my situation, would I proceed by making a www directory similiar to your setup and modifying my rewrite similar to yours?

The only WWW directories in my site are in the following directory paths
home/[root]/public_html/storage/vendor/leafo/scssphp/site/www
home/[root]/public_html/beta/system/storage/vendor/leafo/scssphp/site/www
home/[root]/public_html/beta/storage/vendor/leafo/scssphp/site/www
home/[root]/public_html/storage/vendor/leafo/scssphp/site/www


Thank you again for your help.

New member

Posts

Joined
Wed Jan 17, 2018 4:33 pm

Post by MrPhil » Wed Jan 24, 2018 11:03 pm

I don't know if the OP is still around, but I always ask for these, "why are you using localhost?" There are only two legitimate reasons for setting up a localhost *AMP stack on your PC: 1) you don't have a commercial host yet, and want to play a bit before committing to the expense, or 2) you have a commercial hosting account, but the host lacks some resource that you need (e.g., PHP 7.2) for development or testing work. Otherwise, you should set up a private test/development directory on your commercial server, and work there (password protect it if you wish). That way you will have no nasty surprises with PHP or MySQL or Apache incompatibilities when you try to go live. Also, you will not be tempted to save $5 a month and run a live site off your PC -- hackers know more about security exploits than you ever will, and will eat you alive.

Frankly, if you can't find your "www" directory (or its equivalent), as given in the suggestion, you don't know enough about the structure of your system to safely mess around with it. Just for the record, on an Apache server it is common to have "www" as an alias (symbolic link) to "public_html", as many tools were written for systems that used www as the root, and it is something of a tradition to leave them that way, rather than convert them to public_html.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by villagedefrance » Thu Jan 25, 2018 3:59 am

mmc013 wrote:
Wed Jan 24, 2018 6:47 am
However I don't have a www directory in my in my server root.
Don't worry about the "www" folder!
I only created it myself so I can work with multiple versions of OC.
It is just me organizing my folders :)

OpenCart custom solutions @ https://villagedefrance.net


User avatar
Active Member

Posts

Joined
Wed Oct 13, 2010 10:35 pm
Location - UK

Post by mmc013 » Thu Jan 25, 2018 5:19 am

@villagedefrance
Thank you for the explanation and the response.

@MrPhil
I'm following the same line of thinking as OP and what you're saying makes a lot of sense. My reluctance with creating a private test/development directory on the commercial server was actually the perceived reason for why I was electing to create a localhost copy. Which was perceived security risks.
I thought there would be less complications with cloning a site to localhost environment because of conflicts with the ssl on the live site.
If at all possible, would it be alright if I dropped you a pm to ask you some general questions on this subject? Its apparent that you know a lot more than I do.

New member

Posts

Joined
Wed Jan 17, 2018 4:33 pm

Post by MrPhil » Thu Jan 25, 2018 7:59 am

Unless you have confidential information that you need to give me (I can't imagine why), it is better to discuss in public so that others can learn from the discussion. Give your new directory an unguessable name, password protect it (via your hosting control panel), and play away safely.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm
Who is online

Users browsing this forum: No registered users and 44 guests