Articles of mod rewrite

ProxyPassMatch和mod_rewrite的操作顺序

我在Apache文件夹模式下遇到了Apache 2.4,PHP-FPM和Wordpress Multi用户的情况。 所有非* .php文件都可以在子文件夹中正常工作,就像主要的example.com/subblog/ url一样,但是任何带有.php的文件,如example.com/subblog/wp-login.php都会失败,并且File Not Found来自PHP-FPM。 mod_rewrite文件是: RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ – [L] RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [PT] RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [PT] RewriteRule […]

apache2.2:ldap_userdir + mod-rewrite不能正常工作

我的Apacheconfiguration: DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> IndexStyleSheet "/css/style.css" Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <Location /> AuthName "AUTH" AuthType Basic AuthBasicProvider ldap AuthzLDAPAuthoritative On AuthLDAPBindDN "cn=write,cn=auth,ou=user,dc=example,dc=com" AuthLDAPBindPassword password AuthLDAPURL "ldap://localhost/ou=user,dc=example,dc=com?uid" AuthLDAPGroupAttributeIsDN Off Require valid-user </Location> <Directory /var/www/dir> RewriteEngine On RewriteCond %{LA-U:REMOTE_USER} (.+) RewriteCond […]

httpd将stream量从一个url转发到同一个lan虚拟主机上的另一台机器

我在CentOs 6服务器上运行HTTPD。 我在同一个局域网上有两台服务器。 我只有1个IP地址。 我有2个域指向路由器,我想example1.com处理服务器1和example2.com处理服务器2.路由器可以转发端口80到服务器1.我需要服务器1转发指向example2.com的stream量服务器2。 它不需要干涉其他虚拟主机目标,如下所示: <VirtualHost *:80> DocumentRoot /var/www/html/example1.com ServerName example1.com </VirtualHost> 我尝试了这样使用mod_rewrite: <VirtualHost *:80> ServerName example2.com RewriteEngine On RewriteRule .* http://192.168.1.60$0 [P] </VirtualHost> 但是当我在浏览器中加载example2.com时,它会尝试加载192.168.1.60,这是我看不到的,因为浏览器与2台服务器不在同一个LAN上。 我该怎么做呢?

mod – 重写/ .htaccess问题与Apache 2.4.12

文件结构如下 公共文件: /home/usrname/public_html CGI BIN,运行软件: /home/usrname/public_html/cgi-bin 私有文件: /home/usrname/public_html/_private 数据库: /home/usrname/public_html/_private/data 我想要做的是将下面的代码从Apache 1.3.42转换为Apache 2.4.12 .htaccess文件,在SSLpath中看起来好像有一些变化,我主要是挂断了。 当您尝试使用SSLpath的任何文档时,我都会看到_privatepath,而不是HTML源代码中的public_htmlpath,如CSS,js图像等 我也有一个权限问题,这是要求我在SSL模式下login,这一定是由于其他.htaccess文件之一。 它应该是简单的,但不知何故我没有得到正确的联机规则。 这里是每个.htaccess文件中的代码行。 公共文件:/ home / usrname / public_html RewriteEngine On RewriteCond %{HTTP_HOST} ^99\.00\.99\.000$ RewriteRule ^/?(.*)$ http://www.example.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule ^/?(.*)$ http://www.example.com/$1 [R=301,L] RewriteCond /home/usrname/public_html/%{REQUEST_FILENAME} -f RewriteRule ^(.+) /home/usrname/public_html/$1 [L] RewriteCond /home/usrname/public_html/_private/%{REQUEST_FILENAME} -f RewriteRule ^(.+) /home/usrname/public_html/_private/$1 [L] RewriteRule […]

将.Htaccess重写规则转换为Nginx

我有以下的Apache重写规则,我试图转换为与Nginx的工作。 RewriteRule ^(.*)\/(.*)-(\d{4})(?:-(.*))?$ album.php?artist=$1&album=$2&releaseyear=$3&extra=$4 我希望它只是 location / { rewrite "^/(.*)\/(.*)-(\d{4})(?:-(.*))?$" /album.php?artist=$1&album=$2&releaseyear=$3&extra=$4; } 虽然这不起作用,但是我的重写规则的nginx版本有没有明确的问题?

mod_rewrite不能在web根目录上工作

在下面的Apache / mod_rewriteconfiguration文件中,我得到了root / var / www /上的任何CGI脚本的403禁止错误。我没有得到任何静态文件的错误。 根目录的脚本,即/var/www/random/script.cgi正常工作,没有错误。 在RewritedEngineclosures的情况下,CGI脚本即使在root / var / www / <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks Options SymLinksIfOwnerMatch AllowOverride All <IfModule mod_rewrite.c> RewriteEngine on </IfModule> </Directory> <Directory /var/www/> Options +ExecCGI Options SymLinksIfOwnerMatch Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all AddHandler cgi-script .cgi […]

Apache重写不找path

我正在尝试重写特定请求的内部path。 我有以下url: http : //192.168.0.100/iw/cci/meta/no-injection/iw-mount/default/main/intranet/infozone/pab/WORKAREA/content/htdocs/english/r1713497/pa/ abc.html 该网页有一些服务器端包括。 但是,这是一个网页内容pipe理系统,所以包含的文件在别处。 SSI行是<!–#include virtual="/wxt/wxt40/head.htm" –> 。 还有一个为iw-mount设置的别名。 所以我认为它会试图find包括在http://192.168.0.100/iw/cci/meta/no-injection/iw-mount/wxt/wxt40/head.htm 。 我需要重新映射它在http://192.168.0.100/iw/cci/meta/no-injection/iw-mount/default/main/common/wxt/WORKAREA/content/htdocs/wxt/wxt40/head .htm 。 所以我尝试了一些不同的组合,重写没有运气。 这是我尝试的最后一个: RewriteCond %{ENV:url} ^/iw-mount/.*?/wxt.*$ RewriteRule ^(/iw-mount/).*?(/wxt.*$) $1default/main/common/wxt/WORKAREA/content/htdocs$2 我对理解正则expression式非常好,但是我认为这是我对Apache重写实际上有限的理解,这可能是我的问题。 我阅读了文档,看了一些例子,但不清楚。 所以我想我有2个问题: 我重写URL还是本地path? 任何人都可以让我知道我的重写规则上面有什么问题吗?

使用mod_rewriteredirect.htaccess的规则

我有一个PHP脚本根据查询从数据库dynamic生成内容。 用户可以从文本框中search用户名“mark”。 这些内容由PHP在www.domain.com/?username=mark提供,不过我希望用户看到提供的URL为www.domain.com/username/mark.html。 同样,用户可能会search一个configuration文件(整数)。 该内容在www.domain.com/?profile=2上生成。 我希望用户看到提供的URL为www.domain.com/profile/2.html。 这是可行的吗? 这是我的.htaccess文件: RewriteEngine On RewriteRule ^username/([^/]*)\.html$ /?username=$1 [L] RewriteRule ^realname/([^/]*)\.html$ /?realname=$1 [L] RewriteRule ^profile/([^/]*)\.html$ /?profile=$1 [L] Mod_rewrite已启用,但该文件似乎不工作。

有条件地从Apache2以外的文档根目录中提供文件

我已经inheritance了用PHP编写的Web应用程序。 代码不是最好的,我想开始使用Symfony框架。 这将是一个逐步迁移通过几个版本,所以我需要传统的网页,网页脚本,CSS文件和图像像现在这样工作。 我的计划是将Symfony安装放在项目根目录的子目录中,并将Apache2configuration的文档根目录设置为Symfony目录。 然后我需要设置Apache2来为旧的文档根目录提供旧版脚本。 这是目录结构的前后。 之前: lib htdocs htdocs\index.php htdocs\img\logo.png htdocs\css\styles.css sql-updates 后: lib htdocs htdocs\index.php htdocs\img\logo.png htdocs\css\styles.css sql-updates symfony symfony\app.php htdocs是当前文件的根目录,symfony会是新的文件根目录。 Symfony很大程度上通过app.php脚本工作,所以Symfony代码的大部分请求都会通过。 如果在symfony目录中找不到对页面或文件的任何请求,我希望Apache像以前一样查看htdocs目录。 有没有办法做到这一点,而不移动遗留页面的URI到一个子目录? 例如,如果以前的URI是www.app.com/ascript.php,并且它parsing为htdocs / ascript.php,我不希望将URI更改为类似于www.app.com/legacy/ascript.php。 这可能吗?

使用Apache mod_rewrite将主机重写到子文件夹,但redirect而不是重写

我想通过.htaccess模拟虚拟主机,所以我想重写主机名到子文件夹。 它工作,但在一些URL不重写,但redirect。 这是我的.htacess文件: RewriteEngine on RewriteBase / # Rewrite from subdomains to subfolders with builds RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.ci\.example\.com$ RewriteCond %{REQUEST_URI} !^/builds/ RewriteCond %{REQUEST_URI} !^/robots.txt RewriteRule ^(.*)$ /builds/%2/%1/$1 [PT] # Example project RewriteCond %{HTTP_HOST} ^old\.domain\.com$ [NC,OR] RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] # Rewrite production to master subfolder RewriteCond %{HTTP_HOST} ^www\.example\.com$ RewriteCond %{REQUEST_URI} !^/builds/ […]