Install Joomla in a subdirectory - joomla

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.

Related

Magento URL rewrite and SEO

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

URL Rewrite for joomla

I wanted change this joomla link
http://www.asbhtechsolutions.com/component/search/?searchphrase=all&searchword=simple%20program%20for%20java
to
http://www.asbhtechsolutions.com/search/simple-program-for-java
How can I do this?
If you don't want to write your own router for the search component, the simplest way is to add a redirect to your .htaccess file.
I don't know about your joomla version, but i checked in joomla 1.5.26,
Just got to the joomla/components/com_search/controller.php
and Search the function search(), at the bottom of this function you find the line that call the url with JRoute class.
$this->setRedirect(JRoute::_('index.php'.$uri->toString(array('query', 'fragment')), false));
now dig something your self to change according to your need, or read some documentation on Joomla JRoute, don't forget to change according to your Joomla Version.. Hope this help you..
if you don't have enough experience with .htaccess try renaming htaccess.txt file to .htaccess. It's contained in your root directory of the Joomla installation.
Oh.. I've never seen a question about .htaccess like this before, it's not easy. I do not know if the code below would work. Just give a try to test this in your .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/search/([a-z0-9-_]+)/?$
RewriteRule ^(.*) /component/search/?searchphrase=all&searchword=%1
RewriteCond %{REQUEST_URI} ^/search/([a-z0-9-_]+)/([a-z0-9-_]+)/?$
RewriteRule ^(.*) /component/search/?searchphrase=all&searchword=%1\%20%2
RewriteCond %{REQUEST_URI} ^/search/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)/?$
RewriteRule ^(.*) /component/search/?searchphrase=all&searchword=%1\%20%2\%20%3
RewriteCond %{REQUEST_URI} ^/search/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)/?$
RewriteRule ^(.*) /component/search/?searchphrase=all&searchword=%1\%20%2\%20%3\%20%4

How to remove index.php from a URL from CodeIgniter?

I am new to CodeIgniter. I have an XAMPP server on Windows 8. Everything is fine, but the problem is about my URL, it doesn't look friendly. It looks like localhost/ci/index.php/site/home (where ci is my root folder for CodeIgniter). I want to make the URL more clean, like localhost/ci/home, how can I do it?
My CodeIgniter version is 2.1.2.
I have done some research already, but in most of the cases it says to change the .htaccess file of CodeIgniter. But I have nothing in the .htaccess file; it's empty, except the line "Deny from all".
You can do this, in config/config.php:
$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST']; //you can also leave blank this CI tend to find this by himself
$config['index_page'] = '';
And try the following .htaccess. I use it for many sites, and it satisfies me.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
If it is not working yet, use a phpinfo(); and check if mod_rewrite is enabled. If it is not enabled, you can follow the instructions in Stack Overflow question How do you enable mod_rewrite? to enable that.
If it is not working yet and mod_rewrite is enabled yet, you can try to switch these in config/config.php:
$config['uri_protocol'] = 'AUTO'; //If not working, try one of these:
'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
You need to replace "Deny from all" with this:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
http://ellislab.com/codeigniter/user-guide/general/urls.html
Looking at the official documentation, CodeIgniter URLs:
You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:
RewriteEngine on<br>
RewriteCond $1 !^(index\.php|images|robots\.txt)<br>
RewriteRule ^(.*)$ /index.php/$1 [L]<br>
Also if you are using Apache place .htaccess file in your root web directory. For more information, look in Codeigniter .htaccess.

mod_rewrite with codeigniter

im using shared hosting. i build my web application with codeigniter and my new web directory will be as follows:
/home/projName/public_html/proj_v3/
under this dir, there are index.php, .htaccess. as shown above, i separated different project version in different directories (ie: proj_v1,proj_v2, proj_v3). the web applications allows photo upload and it's stored in /home/projName/public_html/proj_v3/application/uploads. proj_v2 currently has the latest uploaded photo since it's still in use. because i have different version of projects, i want to place directory uploads in a common directory such as /home/projName/public_html. so that for any new version of projects, i won't have to move the upload folder to the new project folder. this might cause downtime.
currently, the .htaccess file in /home/projName/public_html/proj_v2 is:
Options -indexes
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1/ [L]
i have another .htaccess in /home/projName/public_html/ is:
Options All -Indexes
RewriteEngine On
Rewriterule ^(.*)\.*$ proj_v3/index.php/$1/
RewriteOptions MaxRedirects=3
basically how should i go about editing the 2nd .htaccess file in /home/projName/public_html/ so that if the web directory is domain.com/uploads/image.png, it gets the image from /home/projName/public_html/uploads. currently, the 2nd .htaccess file tells domain.com to point /home/projName/public_html/proj_v3
RewriteRule \.(jpe?g|gif|png|wmv|bmp)$ /uploads/$1
Might work for you. You can add other formats as needed.
What you want to do is allow the paths to real files and folders to exist, while redirecting everything else to CodeIgniter, and you can achieve this using this in your second .htaccess file:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Definitely worth reading this article on the CodeIgniter website about mod rewrite
I actually gave a similar answer before: mod_rewrite in Users/<username>/Sites directory on OSX

EE2 removal of index.php put my site down.

I followed the user guide (http://expressionengine.com/user_guide/general/remove_index.php.html) to remove index.php from the url and now my site is completely down. I can't even access the the system directory. I'm not sure what went wrong. I've tried different .htaccess version and removing the htaccess file, but nothing works. EE requires you in the admin panel to change the name of your site’s index page to be blank, which it seems has completely messed up everything now. Since I can't access the CMS to change the field for the sites index page, is there a way to access file and hard code it manually or somewhere in the database I can fix the problem.
My site is running on a MediaTemple GS if that has anything to do with it.
The easiest way is in your config.php file (system/expressionengine/config) look for this line:
$config['index_page'] = "";
Change to:
$config['index_page'] = "index.php";
Once you're up and working again, paste your current htaccess file. Here's the essential bit from my usual build:
# ExpressionEngine rewrite to remove index.php from the URL (but allow EE to access EE folders/files)
# ------------------------------
RewriteCond %{QUERY_STRING} ^(css=.*)$ [NC]
RewriteRule ^(.*)$ /index.php?/%1 [L]
RewriteCond $1 !^(assets|images|themes|favicon\.ico|robots\.txt|index\.php|admin\.php) [NC]
RewriteCond %{QUERY_STRING} !^(ACT=.*)$ [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

Resources