Lighttp Rewrite Rule For Wordpress
星期二, 02. 2. 2010 – Category: Linux-Server
根目录安装是这样的:
url.rewrite-once = (
"^/(.*)?/?files/$" => "index.php",
"^/(.*)?/?files/(.*)" => "wp-content/blogs.php?file=$2",
"^/(wp-.*)$" => "$1",
"^/([_0-9a-zA-Z-]+/)?(wp-.*)" => "$2",
"^/([_0-9a-zA-Z-]+/)?(.*\.php)$" => "$2",
"." => "index.php"
)
wordpress 可以自动实现 域名无 www 向有的跳转,其他程序可以依靠:
$HTTP["host"] !~ "^(www|mail|mysql)\.(domain\.org)$" {
$HTTP["host"] =~ "^(.+\.)?(domain\.org)$" {
url.redirect = (
"^/(.*)" => "http://www.%2/$1"
)
}
}
实现跳转。
Ubuntu下启动Apache对.htaccess 的支持
星期二, 12. 22. 2009 – Category: Linux-Server
步骤:
1. 终端运行
sudo a2enmod
程序提示可供激活的模块名称,输入:
rewrite
2. 修改/etc/apache2/sites-enabled/000-default (该链接指向的是站点配置文件)
把(默认的www目录、或者需要应用.htaccess的目录)下的AllowOverride 属性改为All,保存。
3. 重新加载apache
[...]
Debian/Ubuntu Apache Mod_Rewrite 安装
星期一, 09. 21. 2009 – Category: Linux-Server
在终端中执行,我常常是使用putty 来远程连接的,这样省的在2个操作界面切换。
#debian
a2enmod rewrite
#ubuntu
sudo a2enmod rewrite
指令后,即启用了 Mod_rewrite 模块。
另外,也可以通过将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/apache2/mods-enabled/rewrite.load 来打开 Mod_rewrite 模块。用指令操作就是:
#debian
ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
#ubuntu
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
一点小提示
事实上,当在Debian or Ubuntu 中采用上述做法并重启了 Apache 服务后,仍然无法正常 rewrite 网址。这里,还有一点需要注意的地方:
sudo vim /etc/apache2/sites-enabled/000-default
将其中的:
AllowOverride None
修改为:
AllowOverride All
上面的 /etc/apache2/sites-enabled/000-default 实则为 /etc/apache2/sites-available/default 的连接。而 AllowwOverride None 则会完全忽略 .htaccess 文件,自然其中所定义的 rewrite 规则也就不能生效了。
最后,别忘了使用下列指令来重启 Apache:
#debian
/etc/init.d/apache2 restart
#ubuntu
sudo /etc/init.d/apache2 restart
Windows 下 Apache Virtualhost 设置
星期二, 06. 16. 2009 – Category: Linux-Server
Apache with virtual host on Windows
一个很平常的问题,windows下怎么在apache上设置 virtualhost (虚拟主机),其实很简单。
这儿以xampp 为例。
第一,设置域名解析。
我们需要打开 host 这样一个文件,不同单位 windows 版本,其位置也不近相同,
Windows 3.1/95/98/ME:
c:\windows\hosts
Windows NT/2000/XP Pro:
c:\winnt\system32\drivers\etc\hosts or c:\windows\system32\drivers\etc\hosts
Windows XP Home:
c:\windows\system32\drivers\etc\hosts
Windows Vista:
C:\Windows\System32\Drivers\etc\hosts
用记事本打开 host 文件,如果你是vista,需要以administrator 运行记事本,在最下面添加:
127.0.0.1 wordpress.do
127.0.0.1 websitebaker.do
左边的ip 是这台电脑的IP地址,右边的是虚拟主机名(设置成功后就可以以这个虚拟主机名访问目录)。
第二,编辑httpd-vhosts.conf
用记事本打开httpd-vhosts.conf,该文件在xampp\apache\conf\extra,把下面的代码复制进去。
<VirtualHost *:80>
DocumentRoot /xampplite/htdocs
ServerName localhost
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName websitebaker.do #虚拟主机(virtualhost)
DocumentRoot D:/xampp/htdocs/websitebaker #网站物理地址
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory D:/xampp/htdocs/websitebaker>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName wordpress.do
DocumentRoot D:/xampp/htdocs/wordpress
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory D:/xampp/htdocs/wordpress>
Options [...]
htaccess 的一点用法
星期五, 06. 12. 2009 – Category: Linux-Server
LAMP 环境里可以很容易的通过 .HTACCESS 进行一些网站的设置
网站引索:
DirectoryIndex index.php index.htm index.html
域名重定向,将yaoyingying.com 重定向到 www.yaoyingying.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yaoyingying\.com$ [NC]
RewriteRule ^(.*)$ http://www.yaoyingying.com/$1 [R=301,L]
下面这些对静态页网站的 URL 优化就有很大帮组了,取好每个页面文件的名字,通过 下面的规则进行目录结构式优化。
RewriteRule ^([a-z]+)\/([a-z0-9]+)-([a-z0-9]+)\/$ $1_$2-$3.php [QSA,L]
RewriteRule ^([a-z]+)\/([a-z]+)-([a-z]+)\/$ $1_$2-$3.php [QSA,L]
RewriteRule ^([a-z]+)\/([a-z]+)-([a-z]+)-([a-z]+)\/$ [...]
Apache 通过 .htaccess 对目录加密
星期一, 06. 1. 2009 – Category: Linux-Server
例如有/home/www/website/dir1 目录,需要对/dir1/加密访问,必须输入口令密码才能访问。
在这种情况下,要是/dir1/加密可以通过 .htaccess 和 .htpasswd 的设置来实现
在/home/www/website/dir1下建立.htaccess文件
vi /home/test1/a/.htaccess
文件内容如下
AuthName “===LOGIN===” #随便填写
AuthType Basic
AuthUserFile /home/www/website/dir1/.htpasswd
Require valid-user username
保存退出
账号生成口令
htpasswd -c /home/test1/a/.htpasswd username 系统会要求输入两遍该用户的密码。
修改密码也是同样 htpasswd -c /home/test1/a/.htpasswd username
Apache日志分析
星期六, 05. 2. 2009 – Category: Linux-Server
1,查看apache进程:
ps aux | grep httpd | grep -v grep | wc -l
2,查看80端口的tcp连接:
netstat -tan | grep "ESTABLISHED" | grep ":80" | wc -l
Apache的rewrite的设置参数
星期六, 05. 2. 2009 – Category: Linux-Server
Apache的rewrite的重写非常常用,现总结了一下.
Apache mod_rewrite规则重写的标志一览
R[=code](force redirect) 强制外部重定向
强制在替代字符串加上http://thishost[:thisport]/前缀重定向到外部的URL.如果code不指定,将用缺省的302 HTTP状态码。
F(force URL to be forbidden)禁用URL,返回403HTTP状态码。
Ubuntu Server apt-get install Apache2 & PHP5 & MySQL5
星期二, 03. 3. 2009 – Category: Linux-Server, 代码人生
用apt-get方法安装mysql5 + Apache2 + PHP5+Phpmyadmin:
大家请先看下Ubuntu的WIKI,(http://wiki.ubuntu.org)上面讲的很详细的。但本人按上面做的第一次没有成功。apache2,php5,mysql5都可以运行,就是phpmyadmin不能用。
本人得到的经验是:MYSQL安成功后,一定要先给它设个密码,这上步是不可少的。
此篇只代表个人的观点和经验,可能会片面化和有错误,请大家批评指正,有问题大家一起来讨论!!
关于站长
Google AD
最近文章
- Ubuntu 里 flash 中的汉字显示为框框
- CSS 层最小高度的全兼容写法
- Windows2k3配置PHP服务器环境
- Joomla TinyMCE 中文语言包
- JavaScript Runcode
- Lighttp Rewrite Rule For Wordpress
- IE8 里中英文字体高度不一样
- 南京夫子庙–瞻园一瞥
- 热烈庆祝本站PR荣升至5~~
- 走在乡间的小路上