0

我现在的htaccess:

# Use PHP 5.3
AddType application/x-httpd-php53 .php


RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php

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

# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php

我需要做一个规则,如果有人输入http://www.mypage.com/blog/blablatitle

它将他重定向到http://mypage.com/blog/blablatitle

头版和所有页面都一样。

我正在使用 CodeIgniter,但我认为这在处理 htaccess 时并不那么重要。

这个建议的解决方案在 CodeIgniter 中效果不佳:

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

因为它在地址中添加了 index.php,例如:当我输入:

http://www.mypage.com/blog/blablatitle

它把我重定向到:

http://mypage.com/index.php?/blog/blablatitle

我需要:

http://mypage.com/blog/blablatitle

没有这个规则是可以的(没有索引,php)例如:http://mypage.com/blog/blablatitle

那么,如何改进此重定向规则 som index.php 的任何建议都不会出现在重定向链接中?

4

2 回答 2

1

解决了!;) 你需要把它放在后面

RewriteBase /
于 2012-12-06T11:15:55.090 回答
1

请试试这个:

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]

RewriteRule ^index.php(.*)$ http://%1/$1 [R=301,L]

于 2012-12-06T11:17:21.207 回答