Opencart: SEO URLs not working in the second store - .htaccess

My default store is http://www.mydomain.com/store1
My second store is http://store2.mydomain.com
In the .htaccess file, I have RewriteBase /store1/
In the Admin - Catalog > Information, the About Us page is set to appear in both stores.
This URL works fine: http://www.mydomain.com/store1/about_us
However this URL shows Internal Server Error: http://store2.mydomain.com/about_us
Is it happening because the default store is installed within a folder(/store1/) and not in the root? Is there a way to resolve this issue?

Yes this is caused by the RewriteBase being set. Simply remove the RewriteBase /store1 line from your .htaccess file and that should fix it. Most sites will be able to guess the correct RewriteBase and so it's not necessary. If that doesn't work, you may want to try this solution

Related

Why does this RewriteRule work for all extensions but .php?

This simple RewriteRule that I am using for practicing with .htaccess files works almost always:
RewriteEngine on
RewriteRule ^.*$ test.html
When I have the file flowers.html and I use http://localhost/flowers I get redirected to test.html, however when I rename flowers.html to flowers.php I get a 404 page with the message The requested URL /flowers was not found on this server. Does anyone know what causes this?
EDIT:
When I create an empty file called flowers it does redirect properly to test.html. What is going on here?
This does sound like a conflict with MultiViews, so try adding the following at the top of your .htaccess file to disable MultiViews:
Options -MultiViews
MultiViews is not enabled by default, so maybe this has been enabled in your server config?
When MultiViews (part of mod_negotiation) is enabled, a request for /flowers (no extension) will result in Apache searching for an appropriate file to return (based on mime-type) by trying various file extensions of files found in that directory. This is achieved with an internal subrequest before mod_rewrite runs.
However, it's not clear why this would be a problem in your case if you have no other directives? Since your directive simply rewrites everything to test.html (which should include any subrequests). (I was unable to reproduce this behaviour on my Apache 2.4 test server - hence my initial doubt.)

How to change base_url in drupal 7, fail to find answer online

I am trying to change base_url on my drupal 7 website, but failed to do it and google a lot, still could not solve it .
I am running localhost/drupal "on my local server. but I want to run it like
" localhost ". ( sorry I have to get rid of http://, otherwise it doesnot let me post)
How to get rid of folder in the url. I know I need to change $base_url on sites/default/setting.php to
$base_url = 'localhost'; // NO trailing slash! ( sorry I have to get rid of http://, otherwise it doesnot let me post)
And in the .htaccess file I am so confused what should I change. People online have their own solution, some said they work , some could not . Could someone give me some suggesttion ?
I assume this has to do with where you have placed your files.
In your file system, remove the 'drupal' directory and place all the files within that at /var/www/html ... instead of /var/www/html/drupal, if that's how it is currently set up.
I feel your pain; I've had this trouble myself before and I believe I had to alter both the settings.php and the htaccess (but try one at a time to begin with). I'm fairly sure that the section below in your .htaccess is what needs changing (just remove the hash from in front of the RewriteBase line). If you're unsure of what you're doing, make a copy of your .htaccess as htaccess.txt and then you can always switch back over if things get nasty.
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
I just realised that what you need is a re-write rule in an .htaccess file within your root folder (not the one that's inside the drupal folder). First, undo any edits you've already made, then create an .htaccess file in the same folder that contains your drupal folder and in it, add:
RewriteEngine On
RewriteRule ^$ /drupal [L]
That should send any traffic from the root into the drupal file structure. If you get issues with strange css, or urls that include the /drupal path, you'll need to revisit the other options in the /drupal/.htaccess file and your settings.php file in order to get it all working correctly.
However, going down this route, you may as well just copy all the files and folders into the root directory anyway (as the first answer suggested), assuming you're not going to be running multiple sites. If you do want to be testing multiple sites, you can just change the RewriteRul above to whatever site directory you're wanting to test in future.

Broken links in a Drupal subdomain

Currently I have a site, https://mysite.com/ a working Drupal7 site. I want to have something like this, https://mysite.com/dev in order for me to test the things first on this location before finally uploading it to the main site. What I did was copy the entire folder where all the files located and pasted it inside /dev. I made a duplicate of the DB being used by the main site and edited the file settings.php under sites/default/, edited the base url from https://www.mysite.com/ to https://www.mysite.com/dev. But when I tried navigating the pages using the links(menu, admin) it gives me Page not found response. In addition, I did uncomment this line RewriteBase / on my .htaccess file. I can also log in, but after logging in the links point to the main site like this, https://mysite.com/link1, https://mysite.com/link2 and so on. What did I miss? Can someone please help? Thanks!
I think I finally got it working. I did mention I edited a single line on my .htaccess file which is the RewriteBase / and I did, I promise. I changed it to RewriteBase /dev but when I tested the site, the links still go to the main site as I have mentioned above. What I did was research more on editing .htaccess and somewhere down the road I got here. I lack a few lines of codes which will solve my dilemma, somewhere between RewriteCond and RewriteBase lines. I need to add these lines, RewriteCond %{REQUEST_URI} ^/dev
RewriteRule ^ dev/index.php [L]. After adding these two lines, I tested the site again and it worked like magic. That's it. Thank you guys.

How to set the default website page through htaccess?

I am currently setting up a website from a client on his hosting account. The website address and for some reason doesn't default to .php files (that is: index.php). If I put index.php and there is no index.html file I receive the following error:
If you feel you have reached this page in error, please contact the
web site owner: someemail#example.com If you are the web site owner,
it is possible you have reached this page because: The IP address has
changed. There has been a server misconfiguration. The site may have
been moved to a different server. If you are the owner of this website
and were not expecting to see this page, please contact your hosting
provider.
His hosting is a shared hosting on cpanel.
Use the DirectoryIndex directive in your .htaccess file
DirectoryIndex index.php
The problem was caused by my web-browser cache, as soon as I have cleared my cache it worked!
Try
DirectoryIndex index.php
if that doesn't work you might have to work around it by providing index.html like
<html><frameset rows="*"><frame src="index.php"></frameset></html>
(ofcourse more elaborate)
You can set your default page as the directory index using .htaccess file in 2 ways.
First method
DirectoryIndex yourfile.php
Above code will set 'yourfile.php' as the directory index. But this will applies to all sub folders as well and may occur '404' error for some related urls.
Second method
Use this code to set your handler file for the root directory
RewriteEngine on
RewriteRule ^$ /yourfile.php [L]
If you want to set a handler file for the sub folder, use this one
RewriteEngine on
RewriteRule ^subfolder/$ /yourfile.php [L]
enter image description here
im getting this error...
enter image description here
i found this line in index.php
how to remove this defualt page and make my website live

.htaccess not working in subfolder

I have a couple of sites that are currently under development and I've put them under a specific subfolder for clients/co-workers to view - "http://dev.staffanestberg.com/site-name/". I've run into some problems getting the sites working with .htaccess. I can reach the index page by typing in the url for a site folder but neither img/style/js/etc linking or page rewriting works. Looking for a solution to this, Apache's "RewriteBase" seems to be the most likely one, however I can't get it to work.
Tried
RewriteBase http://dev.staffanestberg.com/site-name/
RewriteBase /site-name
What would be the correct method?
Thanks in advance,
-Staffan
mod_rewrite’s RewriteBase directive does only apply to rewrites using RewriteRule. And that does only apply for requests that are sent to the server.
But if the requested URIs are already wrong, RewriteBase doesn’t do any help. What you could try instead is the HTML element BASE that set’s the base URI for the current document.

Resources