I want clear url for SEO point of view. i have changed and added the following .htaccess code and configuration in main.php
//.htaccess:
======================
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
=================================
//main.php
====================================
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
),
=====================================
this issue is i have a number of links in my application with ?r=controller/method how can i handle it with .htaccess without changing all the URLs format in my application.
Thanks in advance
Page 1 of 1
URL and .htaccess Handle URLs with .htaccess
#2
Posted 26 July 2012 - 03:26 AM
Once you changed CUrlManager::$urlFormat to 'path', all your URLs should automatically take the path form (example.com/controller/action) - provided that you used Yii::app()->createUrl() method to build your URLs. If you hardcoded URLs, then you should replace them all with a call to createUrl() method. This may be a bit more work, but it is the proper way of doing things.
So if you have something like this in your view:
You should replace it with:
Or, if you don't want to create an <a> tag, just call:
So if you have something like this in your view:
<a href='index.php?r=site/login'>Login</a>
You should replace it with:
echo CHtml::link('Login', array('site/index'));
Or, if you don't want to create an <a> tag, just call:
Yii::app()->createUrl('site/index');
#3
Posted 26 July 2012 - 05:37 AM
pavlepredic, on 26 July 2012 - 03:26 AM, said:
Once you changed CUrlManager::$urlFormat to 'path', all your URLs should automatically take the path form (example.com/controller/action) - provided that you used Yii::app()->createUrl() method to build your URLs. If you hardcoded URLs, then you should replace them all with a call to createUrl() method. This may be a bit more work, but it is the proper way of doing things.
So if you have something like this in your view:
You should replace it with:
Or, if you don't want to create an <a> tag, just call:
So if you have something like this in your view:
<a href='index.php?r=site/login'>Login</a>
You should replace it with:
echo CHtml::link('Login', array('site/index'));
Or, if you don't want to create an <a> tag, just call:
Yii::app()->createUrl('site/index');
Thank You very much
#4
Posted 26 July 2012 - 05:39 AM
Can you help me in the following regard:
i have a module like this:
http://localhost/ver...tion/group_id/2
i the group_id=2
when i called this url Error 404 occurs
i have a module like this:
http://localhost/ver...tion/group_id/2
i the group_id=2
when i called this url Error 404 occurs
#5
Posted 07 April 2013 - 09:09 AM
itsallaboutnomy, on 25 July 2012 - 05:53 AM, said:
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
for the life of me, i cannot strip index.php from the URL. No idea why. I have it now that domain.com/index.php/site/login works, but obviously that's the ugliest thing in the world. my .htaccess looks the same as yours. in the same dir was my index.php where i create my yii app.
Any tips? :/
Share this topic:
Page 1 of 1

Help












