Post by chrisgwynne » Wed Sep 13, 2017 8:47 pm

Hi

I've set up a folder on the root of my site called /forum/

However when I access this, Opencart takes over and it turns to a page not found error.

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>

#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# 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/ 


RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
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)
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
How can I alter this?

Kind regards

New member

Posts

Joined
Fri Nov 11, 2016 7:33 am

Post by yodapt » Wed Sep 13, 2017 10:02 pm

After RewriteEngine you need :

Code: Select all

RewriteBase /
.. and you need a .htaccess inside forum folder as well, dunno what you have there though.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by chrisgwynne » Wed Sep 13, 2017 10:15 pm

Hmm just done this

Still having Opencart process the URL and redirecting to a page not found URL.

New member

Posts

Joined
Fri Nov 11, 2016 7:33 am

Post by yodapt » Wed Sep 13, 2017 10:30 pm

What is inside forum folder?

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by MrPhil » Wed Sep 13, 2017 10:51 pm

A forum page request is going through the OpenCart .htaccess (root) before getting to /forum? OC sees "forum", and perhaps is trying to process it as SEO? You may need to add a "guard" RewriteCond to exclude "forum" from any OC-related rewrites/redirects. This is why I always recommend that major applications (such as a store and a forum) be in their own subdirectories, rather than installing in the root.

By the way, you have "www." added at least twice. You can also get rid of some of the RewriteConds automatically added for the SSL stuff, if the URI is for certain things like the sitemap.

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by yodapt » Wed Sep 13, 2017 11:10 pm

There is nothing wrong in having subfolders, but those must have their own .htaccess otherwise the requests will be misinterpreted by Apache.

Opencart Developer - My Extension Showcase
Contact me at aeon.yoda@gmail.com


User avatar
Active Member

Posts

Joined
Fri Jun 17, 2011 6:39 pm


Post by chrisgwynne » Thu Sep 14, 2017 5:33 pm

Thanks for the help guys.

This worked, I just needed a .htaccess file in the new folder. Strange, never knew this before!

New member

Posts

Joined
Fri Nov 11, 2016 7:33 am

Post by MrPhil » Wed Sep 20, 2017 4:13 am

It depends on how your host has configured the server (Apache). My host jumps directly to the indicated directory if the path actually exists. What is supposed to happen is that /.htaccess (which is for OC in this case) is run, then any .htaccess files down the chain are run in turn until control gets to the requested directory. I've never heard of a system failing if you don't have an .htaccess file in a directory, but perhaps it's possible to configure the system that way.

User avatar
Active Member

Posts

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

Users browsing this forum: No registered users and 170 guests