How to open an index.html - redirect

I have a site with two different languages(tr and en). These are in two different folder(tr and en) and each has their own index.html. I want to open tr's index.html at the beginning. My configaration so far;
<VirtualHost #ip-address#:80>
*
*
*
DocumentRoot #path-to-directory#
*
*
*
</VirtualHost>
I tried to add
DirectoryIndex tr/index.html
it did not work.
I tried
DocumentRoot #path-to-directory#/tr
but I could not acces
http://<site-name>/en/index.html
How can I do that? I have tried redirect but it did not work as well.

I am not sure if you are able to force the browser to show the default page, as that sort of defeats it's purpose. The best idea I could think of would be to leave the default as index.html, and use mod_rewrite to direct index.html to app.php.
This should work for the default index ( www.domain.com) and show desired url in browser ( www.domain.com/app.php )
<VirtualHost *:80>
ServerName *.mysite.co.uk
DocumentRoot "/var/www/html/mysite/web/"
DirectoryIndex index.html
RewriteEngine on
RewriteRule ^index\.html$ app.php$1 [L,R=301]
</VirtualHost>

Related

redirect 301 all categories links in wordpress + Redirection plugin

how to redirect all links:
http://www.babynames.ir/esm/oldcat/page1/number/...
to:
http://www.babynames.ir/esm/newcat/page1/number/...
oldcat -> newcat
im using:
Permalink-Finder AND 404 redirect but mess all link.
using Redirection plugin but could not set the parameters...
how about using htaccess like this
add to your .htaccess file after the RewriteEngine On
RedirectMatch 301 http://www.babynames.ir/esm/oldcat/(.*) http://www.babynames.ir/esm/newcat/$1
or may be like this
RewriteRule ^oldcat/?$ $1/newcat$2 [R=301,L]

Redirect root domain homepage to another domain subdirectory

I would like to:
Redirect www.olddomain.com to www.newdomain.com/page
Redirect www.olddomain.com/article1 to www.newdomain.com/article1
Here is what I put into my htaccess file:
redirect 301 / http://www.newdomain.com/page
redirect 301 /article1/ http://www.newdomain.com/article1
The first redirect works, however, the second one does NOT work, since www.olddomain.com/article1 redirects to www.newdomain.com/page/article1, which does not exist and thus returns a 404 error.
How to redirect the old domain home page (root) to a new domain subdirectory, without affecting all other redirects?
In .htaccess code should look like that:
RewriteEngine On
RewriteRule ^/$ http://www.newdomain.com/page [L,R=301]
RewriteRule ^/article1/$ http://www.newdomain.com/article1 [L,R=301]

Zend Framework: only index view renders 404 error when trying to access other views via /controller/action url

I am new to Zend Framework.
I am running Apache 2.2 and have set the DocumentRoot in the httpd.conf file to the public directory created using Zend_Tool.
Within the public directory I have an .htaccess file;
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
...and an index.php file;
<?php
// Define path to application directory
/*defined('APPLICATION_PATH')
|| */define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()->run();
When I type "http://localhost/" into the browser the file index.phtml in the "application/views/scripts/index/" directory is rendered ok.
If I try to access other views using the controller and action names in a url I get a 404 error saying that the requested URL could not be found on the server.
For example I have the controller file TestController.php
which is in the same directory as IndexController.php
/TestController.php/
<?php
class TestController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function testAction()
{
// action body
}
}
I have created a test directory containing a file called index.phtml in "application/views/scripts/";
/views/scripts/test/index.phtml/
<br /><br />
<div id="view-content">
<p>View script for controller <b>Test</b> and script/action name <b>index</b></p>
</div>
When I try to render this file by typing "http://localhost/test/" I get a 404 error stating that the requested URL could not be found. All of the Zend Framework documentation I have read and countless other resources all state that this method should render correctly.
I must be missing something, but after an exhaustive search have been unable to find anyone else having this particular problem.
Regards Roan
try creating an indexAction in the test controller... or test.phtml in the directory
Can you check if the second url localhost/test is going through your index.php.
You can put a die() or some debug statement for that.
Hmm try to add this in your httpd.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot Link to yourSiteFolder exp. C:/AppServ/www/yourSite/public
ServerName youServerName exp. http://mysite.com or you ip http://xxx.xxx.xxx.xxx
</VirtualHost>
<Directory "Link to yourSiteFolder exp. C:/AppServ/www/yourSite/public">
Options FollowSymLinks
AllowOverride All
</Directory>
Find this:
#LoadModule rewrite_module modules/mod_rewrite.so
And delete '#'.
Thanks for your replies.
Thought I would post my solution for others..
Here is the section I updated in the httpd.conf file within the directory tags;
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
and I had previously uncommented the module mentioned above
LoadModule rewrite_module modules/mod_rewrite.so
Cheers

Kohana - controller specific .htaccess

I'm trying to set some htaccess rules for a specific Kohana controller. Basically its to do with form uploads. The majority of the site doesn't want to allow for large uploads so the php.ini will remain with the recommended settings.
However in one place a large file upload is required. I have the following options to add in my root .htaccess:
php_value max_input_time 60000
php_value post_max_size "1GB"
php_value upload_max_filesize "1GB"
php_value memory_limit "128MB"
But I don't know what to do to make it apply just for one controller (i.e. http://www.mysite.com/massiveupload).
Any help would be appreciated.
There's also another solution. Again thanks to #LazyOne for the tip. This one is much neater, but it requires updating the Apache config directly (so you cannot deploy it on a shared hosting).
All you have to do is add this to your httpd.conf or vhosts.conf (inside <Directory> or <VirtualHost> as per Apache Docs).
<LocationMatch /massiveupload>
php_flag max_input_time 60000
php_value post_max_size 1024M
php_value upload_max_filesize 1024M
php_value memory_limit 128M
</LocationMatch>
Restart your server and it should just work!
Note, that although LocationMatch parses the /massiveupload as a regular expression, we cannot use ^/massiveupload (note the ^ char to match beginning of the string). This is because it will fail if you use a ModRewrite (which changes the final request url internally).
Note, you shouldn't make upload_max_filesize and post_max_size the exact same size, because if you upload a file that just reaches the upload_max_filesize limit, any other post data will cause it to exceed the post_max_size and the form submission will fail.
What #LazyOne suggested is fairly easy to accomplish actually.
Consider this folder structure (only listing the most important files/folders):
application/
bootstrap.php
lib/
kohana-3.0.8/
modules/
system/
public_html/ <----- this is your DOCUMENT_ROOT
.htaccess
index.php
And consider you're using default Kohana's .htaccess:
RewriteEngine On
RewriteBase /
<Files .*>
Order Deny,Allow
Deny From All
</Files>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT]
Now create an upload/ folder in your public_html/.
Copy both .htaccess and index.php from your DOCUMENT_ROOT to the upload/ folder.
Edit your upload/.htaccess: (only new changed lines displayed)
php_flag max_input_time 86400
php_value post_max_size 1536M
php_value upload_max_filesize 1024M
RewriteEngine On
RewriteBase /upload/
...
RewriteRule .* index.php/upload/$0 [PT]
Edit your upload/index.php and update all paths ($application, $modules, $system).
You can download the whole tested package
Create an upload controller.
Additionally you could split index.php into two parts (cut after defining the paths) so you don't duplicate the whole file.
Setup like this worked just well for me and you can download my test application from here: http://d.pr/ioYk

strict htaccess for digitalus

after installing digitalus i created the following rule (.htaccess ) file in the root directory
<VirtualHost *:80>
ServerName ecn.local
DocumentRoot /home/speshu/Development/ecn
SetEnv APPLICATION_ENV tinsae
<Directory /home/speshu/Development/ecn>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
and put 127.0.0.1 ecn.local in /etc/hosts
but when i type http://ecn.local/scripts or http://etc.local/library or some existing folder in the document root rather than displaying a not found (404 message ) it lists all the folders in there how can i restrict this
in may earlier projects i remember having such restrictions on zend-framework what is the problem with digitalus since it's built on the same framework ..............
with out modifying in the digitalus
just add Options -Indexes to your wanted folder and it will hide the files (aka 'forbidden message ') like :
Forbidden
You don't have permission to access /library on this server.
for example , if you need to hide the library folder
just create .htaccess file inside of it and write down Options -Indexes
and it will do the job :)