2016-10-26 4 views
0

meinen Code läuft mit url:wie index.php aus meiner url in yii Rahmen zu verbergen

http://localhost/yii/Adminlogin 

.htaccess-Datei

Options +FollowSymLinks 
IndexIgnore */* 
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 
:

http://localhost/yii/index.php/Adminlogin 

ich url aussehen soll

main.php

'urlManager'=>array(
     'urlFormat'=>'path', 
     'showScriptName'=>false, 
     'rules'=>array(
      'redirect/<redirectUrl>'=>'site/index', 
      'login'=>'site/login', 
      'privacy'=>'site/privacy', 
      'password'=>'site/forgot', 
      '<controller:\w+>/<id:\d+>'=>'<controller>/view', 
      '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', 
      '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 
     ), 
    ), 
+0

Mögliche Duplikate von [Wie kann ich die Datei index.php für yii in Apache/.htaccess/mod \ _rewrite ausblenden?] (Http://stackoverflow.com/questions/26061591/how-can-i -hide-the-index-php-Datei-für-yii-in-apache-htaccess-mod-rewrite) –

+0

Sie können diese Dokumentation URL für Ihre Referenz verweisen: http://stackoverflow.com/documentation/yii/6143/ setting-in-your-main-php-datei # t = 201610270410382135132 –

Antwort

1

RewriteRule^index.php [L] statt RewriteRule . index.php

+0

Es funktioniert nicht – Shubhangi

0

verwenden in Ihrem main.php

'urlFormat'=>'path', 
'showScriptName'=>false, 

Und in Ihrer .htaccess Verwendung unten

RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA] 
0

Versuchen Sie, diese

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php(.*) [NC] 
RewriteRule ^(.*)index\.php(.*)$ http://%{HTTP_HOST}$1/$2 [R=301,L] 

oder

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php(.*) [NC] 
RewriteRule ^index\.php(.*)$ http://%{HTTP_HOST}$1 [R=301,L] 
0

Auch ... vergessen Sie nicht Ihre Haupt-Apache-Konfiguration AllowOverride in:

<Directory "/path/to/your/yii.sample/web/"> 
    Options FollowSymLinks Multiviews 
    MultiviewsMatch Any 
    AllowOverride All 
    Require all granted 
    allow from all 
</Directory> 

Ist es möglich, dass Ihr web/.htaccess korrekt ist, aber Ihr Apache erlaubt nie Ihre

0

meine .htaccess würde aussehen wie

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

und in main.php

'urlManager'=>array(
    'urlFormat'=>'path', 
    'showScriptName'=>false, 
    'caseSensitive'=>false, 
    'rules'=>array(
     '<controller:\w+>/<id:\d+>'=>'<controller>/view', 
     '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', 
     '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 
    ), 
),