typo3: realurl extension- configuration issue, include path-fragment in url - .htaccess

Assume I have a website www.mywebsite.com. My typo3 v4.7 frontend is located at, say,
www.mywebsite.com/cms/index.php
, and the backend is located at www.mywebsite.com/cms/typo3/.
How do I configure the "friendly" urls, that the realurl extension generates, in a way that urls are mapped as follows:
www.mywebsite.com/cms/index.php?id=45
to
www.mywebsite.com/cms/something
I want to use the autoconfiguration feature of realurl.
This is how the autoconfig file looks like:
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
'_DEFAULT' =>
array (
'init' =>
array (
'enableCHashCache' => true,
'appendMissingSlash' => 'ifNotFile,redirect',
'adminJumpToBackend' => true,
'enableUrlDecodeCache' => true,
'enableUrlEncodeCache' => true,
'emptyUrlReturnValue' => '/cms/',
),
'pagePath' =>
array (
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'rootpage_id' => '13',
),
'fileName' =>
array (
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' =>
array (
'print' =>
array (
'keyValues' =>
array (
'type' => 98,
),
),
),
),
),
);
?>
I can't get it done. There are more virtual hosts on this website. I don't want to build a new dedicated virtual host just for this typ3 installation.
Currently, redirects do not work. There is a generic with a "Page ... was not found on this server." error-message issued by Apache.
<IfModule mod_rewrite.c>
RewriteEngine on
#RewriteBase /cms/
RewriteRule ^/cms/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)(/.*)?$ - [L]
</IfModule>

Just a tip: instead using TYPO3 in subfolder it's much more comfortable to put it into subdomain like cms.mydomain.com. In such case you don't need an additional re-configuration, and all elements works as it was normal domain.

I think your problem has currently nothing to do with RealURL and its configuration. You have a problem with mod_rewrite configuration. Start with the original one that is shipped with TYPO3 because the bit you posted is missing crucial rules. Try to set the RewriteBase but if it doesn't work, disable it.
Note that it's actually the last rule (RewriteRule .* index.php [L]) that invokes TYPO3 and makes it handle the request, which apparently doesn't happen right now.
<IfModule mod_rewrite.c>
# Enable URL rewriting
RewriteEngine On
# Change this path, if your TYPO3 installation is located in a subdirectory of the website root.
RewriteBase /cms/
# Rule for versioned static files, configured through:
# - $TYPO3_CONF_VARS['BE']['versionNumberInFilename']
# - $TYPO3_CONF_VARS['FE']['versionNumberInFilename']
# IMPORTANT: This rule has to be the very first RewriteCond in order to work!
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]
# Stop rewrite processing, if we are in the typo3/ directory.
# For httpd.conf, use this line instead of the next one:
# RewriteRule ^/TYPO3root/(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
RewriteRule ^(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
# Redirect http://example.com/typo3 to http://example.com/typo3/index_re.php and stop the rewrite processing.
# For httpd.conf, use this line instead of the next one:
# RewriteRule ^/TYPO3root/typo3$ /TYPO3root/typo3/index.php [L]
RewriteRule ^typo3$ typo3/index_re.php [L]
# If the file/symlink/directory does not exist => Redirect to index.php.
# For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
# Main URL rewriting.
# For httpd.conf, use this line instead of the next one:
# RewriteRule .* /TYPO3root/index.php [L]
RewriteRule .* index.php [L]
</IfModule>

Related

Configure Yii2 Advanced on single domain with multiple backends

From: http://www.yiiframework.com/wiki/799/yii2-app-advanced-on-single-domain-apache-nginx/#hh2
It works but I have created another backend.
This is the .htaccess configuration that I have:
RewriteEngine On
# End the processing, if a rewrite already occurred
RewriteRule ^(frontend|backend2)/web/ - [L]
RewriteRule ^(frontend|backend)/web/ - [L]
# Handle the case of backend, skip ([S=1]) the following rule, if current matched
RewriteRule ^backend(/(.*))?$ backend/web/$2 [S=1]
RewriteRule ^backend2(/(.*))?$ backend2/web/$3 [S=2]
# handle the case of frontend
RewriteRule .* frontend/web/$0
# Uncomment the following, if you want speaking URL
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([^/]+/web)/.*$ $1/index.php
Final frontend URL: http:// example.com/ -> OK.
Final backend URL: http:// example.com/backend -> Error 404.
Final another backend URL: http:// example.com/backend2 -> OK.
You need to edit your .htaccess according to this:
RewriteEngine On
# End the processing, if a rewrite already occurred
RewriteRule ^(frontend|backend|backend2)/web/ - [L]
# Handle the case of backend, skip ([S=2]) two following rules, if current matched
RewriteRule ^backend(/(.*))?$ backend/web/$2 [S=2]
# Handle the case of backend2, skip ([S=1]) the following rule, if current matched
RewriteRule ^backend2(/(.*))?$ backend2/web/$2 [S=1]
# handle the case of frontend
RewriteRule .* frontend/web/$0
# Uncomment the following, if you want speaking URL
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([^/]+/web)/.*$ $1/index.php
You need to edit backend2/config/main.php:
....
'components' => [
....
'request'=>[
'baseUrl'=>'/backend2',
],
'urlManager'=>[
'scriptUrl'=>'/backend2/index.php',
],
// use the following, if you want to enable speaking URL for the backend
// 'urlManager' => [
// 'enablePrettyUrl' => true,
// 'showScriptName' => false,
// ],
],
Also, you need to create environments/dev/backend2 and environments/prod/backend2 folders with appropriate content and fix all namespaces and paths to backend2.

CodeIgniter - .htaccess file in captcha folder gets deleted

I have CodeIgniter installed on WAMP in the root directory. The problem comes in here: I've been trying out the captcha's. My captcha folder is C:\wamp\www\captcha. The problem is the .htaccess file inside the captcha gets deleted when a new captcha is generated
The content of the .htacces file is:
RewriteEngine on
RewriteRule !.*\.jpg - [F,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule (.*) - [F]
I use it to return a Forbidden ..... message if the .... .jpg file exists.
At the moment I only have this in the /view file. I haven't yet implemented any check/submit method. I feel I need to overcome this first.
$this->load->helper('captcha');
$vals = array(
'img_path' => './captcha/',
'img_url' => 'http://localhost/captcha/',
'img_width' => '150',
'img_height' => 30,
'expiration' => 25
);
$cap = create_captcha($vals);
echo $cap['image'];
Thanks in advance.
Answer is quite simple acctually: just create a folder inside captcha (in my case images), and edit the files accordingly:
.htaccess (in captcha folder)
RewriteEngine on
RewriteRule ^([0-9]+)\.([0-9]+)\.jpg$ ./images/$1\.$2.jpg [L]
RewriteRule !.*\.jpg - [F,L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule (.*) - [F,L]
other "view" file
$this->load->helper('captcha');
$vals = array(
'img_path' => './captcha/images/',
'img_url' => './captcha/',
'img_width' => '150',
'img_height' => 30,
'expiration' => 3600
);
$cap = create_captcha($vals);
echo $cap['image'];

Yii and .htaccess file on production server

I am new to yii and have some problem in configuring .htaccess file on production server.
On localhost :
Location of Application : /www/connect_donors/
Default URL that yii provides is,
http://localhost/connect_donors/index.php?r=controllerId/functionName
We used the urlManager in /connect_donors/protected/config/main.php to configure the SEO friendly url's..
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>'
Now the URL that was working was
http://localhost/connect_donors/index.php/controllerId/functionName
Then I used the .htaccess file to remove index.php from the above URL.
Location of .htaccess is : /connect_donors/.htaccess
Following is .htaccess file,
RewriteEngine On
RewriteBase /connect_donors
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
URL Chenged to :
http://localhost/connect_donors/controllerId/functionName
Everything working fine and awesome.
But yesterday I uploaded the application on production server.
On Production Server
Everything remained same only I had to change the .htaccess file.
The .htaccess file on server is,
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
Now the following url:
http://donorsconnect.com/
loads the home page of server properly.
But,
http://donorsconnect.com/profile
redirects again to home page.
NOTE : There is no session set on the "profile" controller.
class ProfileController extends CController
{
public function actionIndex()
{
$this->render('index');
}
}
I tried lot of things, changing the .htaccess file to different codes. but none helped me.
Any help is appreciable.
Solution
I finally got the solution and the mistake I had done.
My Components had a request array containing baseUrl.
'components'=>array(
...
'request' => array(
'baseUrl' => 'http://donorsconnect.com',
...),
Due to this it was not loading. I did not find the real reason for that.
But after removing that 'request' array, its loading fine.
Check link,
http://donorsconnect.com/profile
You should not hide index.php like this, read carefully : http://www.yiiframework.com/doc/guide/1.1/en/topics.url#hiding-x-23x
You should set showScriptName to false in your main config :
'urlManager'=>array(
.....
'showScriptName'=>false,
.....
),
And your .htaccess should look like this :
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php

How to remove index.php from URLs in Kohana 3.1

Currently, using Kohana 3.1, I can access my controllers using:
http://localhost/kohana/index.php/admin
However, I would like to access them without the "index.php" in the middle, as in:
http://localhost/kohana/admin
How can I do that? Do I need to change my .htaccess file or some config option?
I'm using the .htaccess provided with Kohana:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
Order Deny,Allow
Deny From All
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# 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/$0 [PT]
However, if you use Rewritebase /kohana/, you will still get index.php in the url.
I'm using Kohana 3, so I go to bootstrap.php and change this:
Kohana::init(array(
'base_url' => '/',
'index_file' => '',
));
Change the RewriteBase directive to where the application is. Yours would be:
# Installation directory
RewriteBase /kohana/
Also make sure you have the correct base_url in your bootstrap.
On some website I saw .htaccess suggestion:
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php?kohana_uri=$0 [PT,L,QSA]
It seems that you miss kohaha folder.
It should be like this:
Kohana::init(array(
'base_url' => '/kohana/',
'index_file' => '',
));
Turn on URL rewriting by adding the following code:
In .htaccess:
RewriteEngine On
# Installation directory
RewriteBase /
In Bootstrap:
Kohana::init(array( 'base_url' => '', 'index_file' => '' ));
You need to use 'index_file' => FALSE in bootstrap.php
Source : http://kohanaframework.org/3.0/guide/kohana/tutorials/clean-urls

Remove "/index/" from URIs in Kohana 3

As of right now all of my controllers are mapped like this:
http://example.com/index/index
http://example.com/index/services
http://example.com/index/contact
What I want to do is change the configuration of the URI to look like this:
http://example.com/index
http://example.com/services
http://example.com/contact
Here is my .htaccess file
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# 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/$0 [PT,L]
My bootstrap.php has the following:
Kohana::init(array(
'base_url' => '/',
'index_file' => FALSE
));
How can this be achieved?
Your .htaccess code looks fine. Check that your Apache configuration is fine:
Kohana URL rewriting
Also, you need to edit your application/bootstrap.php and setup the initialization variables there.
Kohana::init( array(
'base_url' => '/',
'index_file' => FALSE,
) );
You may want to check the user guide, there is a page just for this setup.
http://kohanaframework.org/3.0/guide/kohana/tutorials/clean-urls
I assume that you use action_index, action_services and action_contact inside Controller_Index.
If so, all you need to do is remove the controller section from routes (in your bootstrap.php)
Route::set('posttype', '<param>', array('action' => 'index|services|contact'))
->defaults(array(
'controller'=> 'index',
'action' => 'index'
));

Resources