在Apache中更改站点的URL与mod_rewrite的 [英] Change site URL in Apache with mod_rewrite
问题描述
使用mod_rewrite我的问题是,当我打开我的网站的管理部分我必须写www.example.com/index.php/admin我怎样才能改变我的网站的网址
How can i change my site URL using mod_rewrite my problem is when i open my site's admin section i have to write www.example.com/index.php/admin
我想是我直接打开我的网站像www.example.com/admin请大家帮忙
what i want is i directly open my site like www.example.com/admin please help
感谢
推荐答案
下面是一个的.htaccess
文件从的 codeIgniter 的PHP框架:
Here's a .htaccess
file copied from the CodeIgniter PHP framework:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
这重定向的一切,是不是的index.php
,的robots.txt
上的事图片
文件夹的index.php / $ 1
,其中 $ 1
是URL用户输入
This redirects everything that isn't index.php
, robots.txt
or anything in the images
folder to index.php/$1
, where $1
is the URL the user entered.
您需要这些规则:
- 重定向
的index.php
将导致infinte环 -HTTP://localhost/index.php/index.php/index.php/ ...
-
的robots.txt
的是,搜索引擎使用的一个重要文件。这仅仅是纯文本;你不希望你code处理。 - 您显然想保持其访问您的照片。根据需要为在您的静态资产所在地调整这条道路。
- Redirecting
index.php
would cause an infinte loop -http://localhost/index.php/index.php/index.php/...
robots.txt
is an important file that search engines use. It is just plain text; you don't want it handled by your code.- You obviously want to keep having access to your images. Adjust this path as necessary for where your static assets are located.
这篇关于在Apache中更改站点的URL与mod_rewrite的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!