Page 1 of 1

Problem with redirects and htaccess file

Posted: Sun May 22, 2016 4:28 pm
by cdamianou
Hi

I was wondering if there is anyone that can shed some light into my following issue.

I set up 2 rediects via cPanel to a youtube video that worked fine. The redirects were showing in the htaccess file as normal. I decided to chnage the location of the file the redirect goes to but when i went into cPanel there were no redirects. This wasn't an issue as the redirects were still in the htaccess file. I deleted these redirects and set new ones up for the new location via cPanel. The strange thing is the redirects are still going to the old locations.

The stranger thing is this. If I delete everything in the htaccess file and setup the redirect it works perfectly, but some functionality doesn't work on the site for example the information pages links. If I load up the old htaccess file and add the new redirect, it still redirects to the old youtube video.

Does anyone know what might be causing this? Is there somewhere on the site that has registered this old redirect and it is still in play somehow even though I cannot find a reference to it anywhere?

You help is very much appreciated.

Re: Problem with redirects and htaccess file

Posted: Mon May 23, 2016 1:59 am
by IP_CAM
Better NOT mix up different things, the OC .htaccess file has, fundamentally, nothing to do with any other .htaccess file, possibly placed in your Server Root, and/or any other Sub/Section. BUT if you redirect something in a Root - .htaccess, it still may have some impact on a Shop. So, better set up your server in a proper manner first, or it could end up full of errors. Or then, get a Pro on such 'combined' .htaccess things.
Ernie

Re: Problem with redirects and htaccess file

Posted: Mon May 23, 2016 2:27 am
by cdamianou
Thanks for your reply.

Im not entirely sure what you mean. When I create a redirect via cPanel, the redirect shows in the .htaccess file located public_html/.htaccess

I couldn't locate any other .htaccess file apart from the ones locataed in public_html

Re: Problem with redirects and htaccess file

Posted: Mon May 23, 2016 2:57 am
by IP_CAM
cdamianou wrote:I couldn't locate any other .htaccess file apart from the ones locataed in public_html
But then, what is that supposed to mean !? :o

Re: Problem with redirects and htaccess file

Posted: Mon May 23, 2016 3:06 am
by cdamianou
Exactly that. The only .htaccess file I can locate is in the public_html folder.

Re: Problem with redirects and htaccess file

Posted: Mon May 23, 2016 3:25 am
by IP_CAM
sorry, I figured, from reading, you may succeeded in placing more... :D

Ok, in your shop software main directory, the is a file, called: .htaccess.txt, wich has to be
renamed to .htaccess, and first internally linked, before uploaded, to match
the SUB-Directory, where your shop has been placed.
Ernie
unfortunately, I have been blocked (again!), from accessing my own postings on this, here, so,
I cannot link them here. :crazy: It's a fun place... ;)
---
Lots of information on htaccess can be found here:
https://www.google.com/search?q=opencar ... Oka5aPibAL

Re: Problem with redirects and htaccess file

Posted: Mon May 23, 2016 3:46 am
by cdamianou
This is what's in my htaccess file. At the end you an see the current redirect. For some reason it is still being redirected t the old YouTube redirect.

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

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
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

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^bazingabox$ "http\:\/\/XXXXXXX\.co\.uk\/explanations\/bazingabox\.html" [R=301,L]

Re: Problem with redirects and htaccess file

Posted: Mon May 23, 2016 4:48 am
by IP_CAM
because of this here. probably:

Code: Select all

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^bazingabox$ "http\:\/\/XXXXXXX\.co\.uk\/explanations\/bazingabox\.html" [R=301,L]
Ernie

Re: Problem with redirects and htaccess file

Posted: Mon May 23, 2016 6:17 pm
by cdamianou
Hi Ernie

I changed the domain to xxxxx as I didn't want to make it public.

You can see that the redirect is set ok. But the redirect goes to youtube rather then /explanations\/bazingabox\.html

But if I clear the htaccess file and just have this redirect, it works as it should.

Re: Problem with redirects and htaccess file

Posted: Tue May 24, 2016 2:33 am
by IP_CAM
I just recall, to have been reading, that you used C-Panel to add routing-content to the .htaccess-file. It could therefore be possible, that a 'hidden' SERVER System .htaccess-type file exists, specifically for your 'Account', wich possibly cannot be seen/handled directly by use of an FTP-Client, and therefore should be changed as well.

On my Server, CUSTOM SERVER SIDE PHP SYSTEM Modifications are then placed visibly
into the Site ROOT Section, and named:
.user.ini
presently containing Site Configuration Information, such as:
[PHP]
memory_limit = 640M

to be system-valid for this individual URL/SITE only, after defining such in my Server ADMIN PHP Setting Sections.

I assume, that it could be, that your Hoster has a Setup, similar to such, C-Panel enabled, and valid, as soon as you
activate your (or any !?) Site .htaccess file. Who knows?

It's a wild idea, but better check on such too.
But since C-Panel is unfamiliar to me, I have no Clue... 8)
rgds,
Ernie

Re: Problem with redirects and htaccess file

Posted: Tue May 24, 2016 6:08 am
by victorj
cpanel needs a empty .htaccess, if not empty like in opncart .htaccess, redirects will be appended to end off file.
redirects to other sites will have to be at beginning of .htaccess before the rewrite rules op opencart.

So you can create the rewrite rules, but copy them from end of .htaccess to the top of .htaccess.
make sure that you have statement RewriteEngine On in front of the rewrites.

also consider that if you use chrome or firefox, they tend to keep old info in browser, so if you visited old url, changed it and revisit, it will still show old ulr, so make sure you clear browser cache before testing, close browser and reopen and restest.

Re: Problem with redirects and htaccess file

Posted: Tue May 24, 2016 7:29 pm
by cdamianou
victorj WOW WOW WOW thank you. That has worked. Thank you very much. And thank you to Ernie as well for your initial help.