2015-10-17 68 views
0

我看了幾個堆棧溢出問題,從子域刪除index.php url請不要標記爲重複。從子域codeigniter刪除index.php 3

堆棧溢出我已閱讀並嘗試。

CodeIgniter in subdomain folder, removing the index.php from address

remove index.php of codeigniter subdomains

Removing index.php and handling subdomains of two Codeigniter sites, when one within the other

但非似乎我使用WAMP笨3並啓用MOD重寫工作。我也使用虛擬主機。

Question: What is the best suitable htacces for sub domain so that I can have the index.php remove?

頁錯誤:

codeigniter 500 internal server error 

我的文件夾結構

www/
www/codeigniter/cms-1 <-- This is main project 
www/codeigniter/cms-1/application 

www/codeigniter/cms-1/cms-2 <-- This is sub domain 
www/codeigniter/cms-1/cms-2/index.php 
www/codeigniter/cms-1/cms-2/.htaccess 

www/codeigniter/cms-1/image/
www/codeigniter/cms-1/system 
www/codeigniter/cms-1/.htaccess 
www/codeigniter/cms-1/index.php 

當我有URL上WAMP像下面不起作用。

http://www.cms-2.cms-1.com/information/information/3

但是,當我有index.php的作品。

http://www.cms-2.cms-1.com/index.php/information/information/3

我對application > config > config.php

$config['index_page'] = ''; 

This .htaccess below is on Main directory and works fine for main domain.

Options +FollowSymLinks 

# Prevent Directoy listing 
Options -Indexes 

# Prevent Direct Access to files 

<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))"> 
    Order deny,allow 
    Deny from all 
</FilesMatch> 

DirectoryIndex index.php 
RewriteEngine on 
RewriteCond $1 !^(index\.php|images|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 [L,QSA] 

回答

3

使用此刪除:

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

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 
+0

沒有運氣進入內部服務器錯誤 – user4419336

+0

更新檢查這個現在 –

+0

謝謝您的幫助,我發現了什麼是錯誤的。 + 1 – user4419336

1

更換你BASE_URL

if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on"){$ssl_set = "s";} else{$ssl_set = "";} 
$config['base_url'] = 'http'.$ssl_set.'://'.$_SERVER['HTTP_HOST']; 

在.htaccess

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

詳細閱讀本http://w3code.in/2015/10/how-to-make-multiple-websitesubdomain-of-your-main-site-in-codeigniter-with-same-code-and-database-dynamically/