Opencart SEO rewrite 404 error - php

I am working for someone who runs a webshop. Now the webshop runs on Opencart software, and fortunately they support SEO Url rewriting. I have been trying to get this working for the last 2 hours and havent been able to get it right. I have done the following to the .htaccess file.
# 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 /opencart/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]
Additionally i have enabled SEO rewriting on opencart and given all products/categories etc. a SEO name.
Now the .htaccess file is located in: public_html/opencart/ so i have changed the RewriteBase from / to /opencart/
Still i get the following errors:
Not Found
The requested URL /aquaria/adm-aquaria was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Does anyone have a solution for me?
To give you an example i want the following link: http://aquadeco.eu/index.php?route=product/category&path=94_291 to look like this: http://aquadeco.eu/aquaria/adm-aquaria

You don't have to put this
RewriteBase /opencart/
If your url are like this yourDomain.com/opencart/index.... Then
you will have to put RewriteBase /opencart/
end if; :)
with your url you don't have to put RewriteBase /opencart/
only /
Regards

Ok, wow i just found out i have been stupid the whole time. I had 2 .htaccess files. One which was the original without the right rewrite rules and 1 in my /opencart/ folder which had the right rewrite rules. What i did now is put the right rewrite rules into the .htaccess file in my root folder and it fixed the problem!! :D

You put your site in sub directory so you have to make following changes
RewriteBase /opencart/ change to RewriteBase /
and
RewriteRule ^([^?]*) index.php?route=$1 [L,QSA] change to
RewriteRule ^([^?]*) /opencart/index.php?route=$1 [L,QSA]

Related

Opencart SEO URL 404 not found

After enabling SEO URLs in OpenCart admin panel, all the links return 404 - not found.
My .htaccess file
# 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=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]
The site is located in /var/www/html/opencurt, I am trying to change to RewriteBase /opencurt, but it doesn't help me. I also cleared my cache.
The current URL on my local machine is http://127.0.0.1/
I know it's common problem, but I can't resolve it by myself.
Firs of all - take default .htaccess.txt file form your versions OpenCart pakage.
Now, you have to rename .htaccess.txt into .htaccess. It's not so easy on Windows. Open it with notepad and then Save As the file, renaming it to .htaccess without .txt.
Although, make sure that you are using Apache webserver, because only
If you are using address like this http://127.0.0.1/ - your rewrite base is RewriteBase /.
In SEO URL you should use only Latin symbols, digits, minus(-) and underscore (_). No spaces or other special characters.
UPDATED
There is SEO field in every category, product, manufacturer. You should fill SEO field of each of them to SEO URL (or better SEO PRO) works correct.
UPDATED 2
If apache doesn't see .htaccess file - you should go to apache .conf file and add after VirtualHost block
<Directory /var/www/html/your_folder/>
Options Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Directory - is a path from your virtual server root. Restart apache. Should work.

Running POST request to php script which sends contact mail from within wordpress subfolder results in 404 Not found

I've just read so much about this issue, but I'm lost here. Can't make this s*$%& work. Here's the issue. Graphic designer has a working WordPress, of which I know same as nothing, about some kindergarten in the city. She builds a landing page to throw a marketing campaign within a subfolder landing201812 inside the public_html folder of the hosting space. The WordPress is installed/deployed/whatever at the root of the site.
Site: https://www.newmills.com.ar/
Landing: https://www.newmills.com.ar/landing201812/
Directories:
public_html/
- lots_of_wordpress_rubbish
- .htaccess
- landing201812/
- sendform.php
Reading about wordpress bootstrapping way for processing all the requests, I have altered the .htaccess file in public_html so it excludes the rewriting of wordpress and goes straight to the landing site.
Original content:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Actual content
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^landing201812/?.* - [L] # My added rule
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
With both configurations, the static content (html/css/media) is served correctly, but, any php I would like to execute within that landing201812 folder, fails with a 404 Not Found error. I have tried also to exclude any landing201812 route with RewriteCond directives from the last RewriteRule like
RewriteCond %{REQUEST_URI} !.*landing201812.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
But the results are the same.
I am quite limited to move around the wordpress since I know nothing about wordpress. I have considered moving it to a subfolder of the public_html, but I'm afraid of breaking it, or its URLs. I have tried to disable the permalinks, but there's no On/Off switch that I could find.
Last, but in case you may wonder, I have tried including another .htaccess file inside my landing201812 folder. RewriteEngine Off did not work as much as the alternative I took from a native wordpress subfolder:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /landing201812/
RewriteRule ^.*\.php$ - [L]
</IfModule>
# END WordPress
So... does anyone know what's wrong, or even better, how to fix this issue? Everyone says on the web that I should be fine with the htaccess rule, or disabling the permalinks, or moving the wordpress to a subfolder and not the root folder. Moving it is the last thing I would like to do, because I won't know how to fix it if it breaks. Am I missing something? Is there any log I should check?
Thanks in advance for any help.
if you are using cpanel, this is not necessary to do in .htaccess
Instead, can you please keep the original wordpress .htaccess and just assign permissions with filezilla to 775 to the folder?
Also, there should be a configuration missmatch, please try re-loading the PHP version in CPANEL (with PHP MANAGER) only to that folder.
If you can provide access to the site in private, maybe I can give you a hand.
It seems to me that if you were to keep the origional WordPress .htaccess and change your file structure to the following it will work at /landing201812/:
public_html/
- lots_of_wordpress_rubbish (not my opinion, just here to match OP)
- .htaccess
- landing201812/
- index.php
The key is naming the file index.php. Otherwise, you can call the file by name like so: /landing201812/sendform.php.

how to rewrite wp-admin url to some other folder using htaccess?

I tried to rewrite a simple RewriteRule but i guess it doesn't turn up good. I created a htaccess file in wordpress wp-admin folder and i tried to rename the wp-admin directory name in my localhost.Here is the code i tried
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^wp-admin$ hello
Just for testing i had done this in my localhost. I want to start from simple pattern not complex pattern so i tried other simple pattern wp-admin and replacement as hello
RewriteEngine On # Turn on the rewriting engine
RewriteRule wp-admin hello
When i go to http://localhost/my_site/hello i can't able to direct to wp-admin for this am getting 404 error. When i try http://localhost/my_site/wp-admin am getting internal server error.
I think the rewrite rule is not good in my try. I have one more doubt should place the .htaccess file in the wp-admin directory or in the my site root directory in my_site or should i place in every directory which am trying to change the folder name on the fly.
What wrong am i doing here.Any help please?
RewriteRule ^hello(.*)$ wp-admin$1 [QSA]
Will change:
http://yourdomain.com/yourwp/hello
http://yourdomain.com/yourwp/hello/path/in/admin
to
http://yourdomain.com/yourwp/wp-admin
http://yourdomain.com/yourwp/wp-admin/path/in/admin
The QSA flag is useful for compatibility.
Here is my wordpress .htaccess with only one custom redirect, but you can understand the idea:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^login/?$ /wp-login.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

kohana htaccess and index structure

I am using kohana 3.2
My site is www.mysite.com/best, kohana is installed on best.
I am using the default htaccess file with rewritebase /best
so what is the best way to redirect users that go to www.mysite.com?
Right now if someone puts www.mysite.com/helo (www.mysite.com/best/helo)
It loads but apache gives 404 not found.
I hope my question makes sense.
EDIT
If a user goes to main domain (www.mysite.com) I want it to load kohana located at mysite/best.
but if a user right now types the full thing and omits best, site will load but my forms wont work because it is posting to www.mysite.com/helo not www.mysite.com/best/helo
instead of loading the fake helo controller, it must show a page not found.
EDIT
Ok I added this to htaccess file and it works perfectly
RewriteCond %{REQUEST_URI} !^/best/
RewriteRule ^(.*)$ /best/$1
You can't have multiple rewritebase in htaccess so...
rewrite your rules to fit you need in /best
or put an other htaccess in / to rewrite your needs.
Try this .htaccess instead:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /best/
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
#RewriteRule .* index.php?kohana_uri=$0 [PT,L,QSA]
RewriteRule .* index.php?/$0 [PT,L,QSA]
Note that the trailing / on RewriteBase is required.

htaccess html > php redirect + Wordpress rewrite permalinks structure

I have started a site up using html only, switched it over to php to make my life easier and have used the following code in the .htaccess to ensure all users (who may have bookmarked) are still seeing the right pages:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.html$ http://domain.com/$1.php [R,NC]
Now I am working on the news section a wordpress blog (inside a /news directory) that would be lovely to use permalinks with, when I slap the rewrite code below into my .htaccess all my files outside of the wordpress directory default to wordpresses 404, they still have the correct address in the bar, but no information.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /news/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news/index.php [L]
</IfModule>
Can anyone help on the correct structure for the .htaccess - I tend to use snippets for specific tasks rather than write htaccess stuff.
Thanks
Your rules have to be come before the Wordpress rules and you need to add an [L] to your RewriteRule:
RewriteRule ^(.+)\.html$ http://domain.com/$1.php [R,NC,L]
Which will tell .htaccess to stop processing rules.
I would recommend a permanent (301) redirect so Google and the other search engines will update their listings:
RewriteRule ^(.+)\.html$ http://domain.com/$1.php [R=301,NC,L]

Categories