Lothor
(Fabiano Lothor)
1
How do I make my site do not be accessed via the link:
"http://<url>/index.php"
My URL Manager:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => true,
'rules' => array(
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
gbasto
(Goncalo Basto)
2
Hi,
You have to configure an .htaccess file. Here it is a good article about this subject: http://www.yiiframework.com/wiki/214/url-hide-index-php/
Lothor
(Fabiano Lothor)
3
Thanks for your reply.
My file (.htaccess) is already configured.
RewriteEngine on
RewriteBase /~my.repository/my_project/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
That is not the issue.
The friendly URLs are working, but the site can be accessed at the link below:
"http://<url>/index.php"
I do not want the site to be accessible from this link.
Do not want to let the user know that the site is PHP.
Lothor
(Fabiano Lothor)
4
The guys do not like to answer my topic or is it because there’s no way it? = /
abennouna
(Abennouna)
5
Maybe it was ambiguous, if I understand, you want that the browser hides index.php even if the user types it in the address, right?
If that’s what you want, you need a rewrite rule, check here: http://www.patricktaylor.com/mod_rewrite-hideindex
Lothor
(Fabiano Lothor)
6
I’m trying to hide the technology that I’m using.
The problem was partially solved as follows:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'caseSensitive' => true,
'urlSuffix' => '.html', // ADD
'useStrictParsing' => true, // ADD
'rules' => array(
'' => array('site/index') // ADD
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
The above configuration works great and completely hides the technology being used.
The problem is that if I access the site without setting the controller and action to be performed, rather than the Home page displays an error page.
"http://<url>/site/index" // Work
"http://<url>/" // Not Work =/
Lothor
(Fabiano Lothor)
7
Using the code below…
'urlManager' => array(
'urlFormat' => 'path',
'urlSuffix' => '.html',
'showScriptName' => false,
'caseSensitive' => true,
'useStrictParsing' => true,
'rules' => array(
'' => array('site/index', 'urlSuffix' => ''),
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
I can access the link:
"http://<url>/"
Great, but then I release also access to the link:
"http://<url>/index.php"
#Edit
Sorry for the multiple posts, but I think I solved the problem.
The following is for those who need to use in your projects.
'urlManager' => array(
'urlFormat' => 'path',
'urlSuffix' => '.html',
'showScriptName' => false,
'caseSensitive' => true,
'useStrictParsing' => true,
'rules' => array(
'' => array('site/index', 'urlSuffix' => '', 'useStrictParsing' => true),
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
abennouna
(Abennouna)
8
Have you seen the blog post I’ve referenced in my previous post?
Lothor
(Fabiano Lothor)
9
I hate to keep using the .htacces for all…
Fortunately I managed to solve the problem using only settings framework.
abennouna
(Abennouna)
10
That’s great, I’m gonna try it some day