PDA

View Full Version : حذف نام پوشه web در آدرس دهی Yii نسخه Basic



webnevesht
پنج شنبه 23 بهمن 1393, 12:39 عصر
سلام. من از محیط ویندوز و Xampp استفاده میکنم برای انجام دادن پروژه هام.
شروع کردم با Yii2 نسخه Basic کار کنم.
فرض کنین آدرس پروژه من در لوکال اینه:


http://localhost/yiiproject/web/


و کانفیگ urlManager از فایل کانفیگ Yii هم اینه:


'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => [
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
],
],





و همینطور فایل .htaccess من هم اینه:



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




ممنون میشم راهنمایی کنین که چطوری میتونم عبارت web رو از توی آدرسم بردارم.
که آدرسم به این شکل تبدیل بشه:



http://localhost/yiiproject/controllername/actionName

^Saeed
شنبه 25 بهمن 1393, 01:12 صبح
سلام. محتویات پوشه web را به روت سایت منتقل کنید و فایل index.php را به شکل زیر تغییر بدهید :



// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require(__DIR__ . '/vendor/autoload.php');
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');

$config = require(__DIR__ . '/config/web.php');

(new yii\web\Application($config))->run();