Magento URL rewrite and SEO - magento

The website is in a sub-folder:
www.example.com/sub-folder/index.php/webpage.html
How do I hide /sub-folder/index.php/ to make the displayed URL www.example.com/webpage.html? Does hiding it affect SEO at all?

Technically it is ideal to be without /sub-folder/, but it would not matter that much if you have it under the subfolder directory as long as you take care of the other onpage factors on your shop.
Why don't you move the website to the root directory?

If the magento installed under /shop or directory then add the following rules into ” /home/username/public_html/shop/.htaccess ” file.
<IfModule mod_rewrite.c>RewriteEngine On
RewriteBase /shop/RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]</IfModule>
check this link http://roshanlal.in/magento/how-to-remove-index-php-in-url-with-magento/
hope this will help you

Related

Magento website shows index.php

I have developed magento site I just want to remove index.php from URL and I did successfully by adding below code in .htaccess
RewriteEngine On<br/>
RewriteBase /<br/>
RewriteRule ^index\.php$ - [L]<br/>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>
RewriteRule . /index.php [L]
But the website is visible, when I'm trying hit https://tumree.com/index.php
In SEO perpective, there shouldn't be duplicate in URL. The two URLs are indexing and its not good.
Please help me to fix the issue...

Install Joomla in a subdirectory

As some of you may know, Wordpress has an options in settings to allow site installation in a subdirectory, while having the site URL be the main domain. It was something like "Site url" and "Wordpress url". I'm looking for something like this in Joomla. I know there is no inbuilt option for it, but I'd rather not have to move all the files if possible. And please, explain it to me like to a five year old, just in case :)
To move the whole joomla installation to a subfolder on the server (http://example.com/subdir), but still access it from the root (http://example.com) I did the following:
Move your whole installation to the subdir-folder
In configuration.php, set $live_site = "http://example.com";
Also change the tmp and log-folders in configuration.php
Add a .htaccess-file to the root-folder:
(The code is modified from this excellent answer)
RewriteEngine on
RewriteCond %{THE_REQUEST} subdir/
RewriteRule ^subdir/(.*) http://example.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !subdir/
RewriteRule ^(.*)$ /subdir/$1 [L]
Modify the default joomla .htaccess-file, now in the /subdir-folder, to include a RewriteBase:
RewriteBase /subdir/
After these modifications it seems everything works the way it should.
You can override the file /includes/defines.php in your joomla installation. Copy this file to the root folder of your installation, and then change all folder names to how you like your setup.
In /index.php you see how it first checks if /defines.php exists. Then it goes on to load /includes/defines.php if _JDEFINES is not defined. So be sure to include
define('_JDEFINES', 'TRUE');
in your overridden /defines.php-file. Good luck :)
Below is how index.php loads folder definitions:
if (file_exists(__DIR__ . '/defines.php')){
include_once __DIR__ . '/defines.php';
}
if (!defined('_JDEFINES')){
define('JPATH_BASE', __DIR__);
require_once JPATH_BASE . '/includes/defines.php';
}
I see now that you are able to override folder locations in /administrator in a similar matter, copy /administrator/includes/defines.php to /administrator and override folders here.
I have used an extension called Virtual Domains for this before. According to them it provides
Multi-domain capability for Joomla without changing the Joomla core
files.
. Which I have made use of previously and it works well
I first tried the accepted answer. However, that answer also redirects existing files and folders to the new subdir.
For this reason I used:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subdir/index.php [L]
instead.
I'm aware that this is not the best solution as it doesn't hide the sub directory properly. However, it allows to keep the existing code on that site working.

RewriteRule doesn't do anything

I am using the current set of re-write rules in my .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule lessons/(.*)$ page.php?url=$1
It works fine. Now I have some old pages which I would like to redirect to new pages. I do the following:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule lessons/(.*)$ page.php?url=$1
RewriteRule old/this_url/(.*)$ lessons/to_this_url/and_this_url
But when I go to www.mywebsite.com/old/this_url/another_path it simply doesn't do anything?
I tested the rule in a re-write test program and it worked. The rule was recognised. So not sure, what I am doing wrong on the live website?
Answering my own question. In fact I realized a bit late that what I was trying to do was redirecting the content of an old website to a new website. They live under the same domain name but don't live under the same root. One lives under / (the current one) and the old one lives under /old/. So the rules needed to be added to the .htaccess of the old website. In:
www.root.com/old/.htaccess (THIS IS CORRECT)
While I was trying to edit them in:
www.root.com/.htaccess (NO)
That solves my problem.

.htaccess "Ignore all rules if link starts with..."

In my root folder I have installed wordpress and there is also my submenu.php that can not be loaded with ajax if I use rules for /%postname%/ (in default )
So this is what WP gave me
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
What do I need to add so that calling
$('#submenu').load('submenu.php?cat=4');
works again?
This is not the way you should be performing AJAX within WordPress.
I suggest you read up on Using AJAX within WordPress from the codex.
I am not really good with htaccess, but this
RewriteRule !^media/ index.php [L]
Will redirect everything except media/* to index, so something like this should work
RewriteRule !^yourscript.php index.php [L]
Note: I agree with Jason there, using it without htaccess is better.

ExpressionEngine: mod_rewrite directory to subdomain, while removing /index.php/

In ExpressionEngine, what’s the best way to mod_rewrite a directory to a subdomain, while keeping index.php out of the picture?
For example:
http://www.domain.com/index.php/group/template -> group.domain.com/template
I’ve seen variations that take ANY group and rewrite them to subdomains, but I only need one.
I’ve been tasked with porting over a subsite from a different server (that was also running EE). Normally, I’d just redirect group.domain.com to domain.com/group (index.php removal was already working), but that’s been deemed an unacceptable solution. And of course, this is time-sensitive.
I’ve been diving into Google and the EE docs/wiki for going on twelve hours and I’m starting to go cross-eyed. Can anyone give me a hand?
Thanks in advance.
Here's how I would craft your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(group|group/.*)$
RewriteRule ^(.*)$ http://group.domain.com/template/$1 [L]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
This example uses the "File and Directory Check" Method of removing index.php from the URL and uses a RewriteCond Directive to instruct Apache to handle the requests for the "group" directory and all its sub-directories differently.
Any links to domain.com/group/template will be redirected to group.domain.com/template/.
If you care about letting crawlers know your content has moved and want to make the transition as seamless as possible, you can add a 301 Redirect to your RewriteRule:
RewriteCond %{REQUEST_URI} ^/(group|group/.*)$
RewriteRule ^(.*)$ http://group.domain.com/template/$1 [R=301,L]
This will ensure that users and search engines are directed to the correct page.

Resources