2017-08-14 149 views
0

我有一個codeigniter網站,我想做seo。所以我使用路由緩慢的URL而不是codeigniter默認的方法名稱和索引。 隨着這個問題發揮作用,三個不同的網址,它打開同一頁面,即。Codeigniter htaccess重定向不重定向到所需的網址

1. https://www.example.com/seo-freindly-url/ 
2. https://www.example.com/index.php?/controller/method/42 
3. https://www.example.com/controller/method/42 

但我想只有第一個URL工作,爲別人,我想只用htaccess的重定向重定向到搜索引擎友好的一個。 請幫助我。 還有一兩件事,我用htaccess的301重定向來重定向我的網址之一

Redirect 301 "/plan/index/42" https://www.example.com/services/seo 

它可以在一定程度上,每當我打開URL

https://www.example.com/plan/index/42 

它重定向到

https://www.example.com/services/seo?/plan/index/42 

但它必須是https://www.example.com/services/seo/

謝謝。

回答

0

很難測試我的結束,但你可以嘗試這樣的事:

的.htaccess

RewriteEngine On 
RewriteBase/

RewriteRule ^controller/method/42$ /seo-friendly-url [L] 

redirect 301 /plan/index/42 /services/seo 

RewriteRule ^(system|application|cgi-bin) - [F,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# Remove index.php from all URLs 
RewriteRule .* index.php/$0 [PT,L] 

/應用/配置/配置

// This assumes you want to remove index.php from all URLs 
$config['index_page'] = '';