我正在尝试构build一个重写条件和规则,用& 在查询string中,而不仅仅是&。 当URL以XML格式传输到客户端时,会发生这种情况,因为编码无效。 长期来说,这将是固定的,但短期来说,如果我可以把一个重写规则,将停止404错误。 示例URL是 https://myserver.com/getpdf/download?md5=53d64aee8107d8f8af0c&id=163464591&tz=GMT 到目前为止我已经得到了这个 RewriteCond %{REQUEST_URI} ^/getpdf/download* RewriteRule ^/([^&]+)(&)(.*)$ /$1&$2 [N] 基于serverfault上的其他职位(例如mod-rewrite:replaceurl中的一些字符 ) 我打开了重写日志,这就是我所看到的 10.0.0.64 – – [12/Mar/2016:06:42:52 +0000] [myserver.com/sid#7f24e32103e8][rid#7f24e3379870/initial] (2) init rewrite engine with requested uri /getpdf/download 10.0.0.64 – – [12/Mar/2016:06:42:52 +0000] [myserver.com/sid#7f24e32103e8][rid#7f24e3379870/initial] (3) applying pattern '^(md5)([^&]+)(&)(.*)$' to uri '/getpdf/download' 10.0.0.64 – – [12/Mar/2016:06:42:52 +0000] [myserver.com/sid#7f24e32103e8][rid#7f24e3379870/initial] (1) pass through /getpdf/download 任何关于如何正确地形成重写小册子的指导都是很好的。
我最近上传了一个PHP主题在我的服务器上。 除了我的主页,其他任何部分都可以正常工作。 例如,当访问www.mywebsite.com/anything主题正在工作,但在主页www.mywebsite.com显示服务器的默认页面。 我正在玩htacess RewriteEngine,它在某些情况下工作,但可能不正确。 这是我迄今为止: <IfModule mod_rewrite.c> RewriteEngine on Options -Multiviews RewriteCond %{REQUEST_URI} !-d RewriteCond %{REQUEST_URI} !-f RewriteRule ^(.*)?$ index.php?a=$1 [QSA,NC,L] ErrorDocument 404 /new/404.php </IfModule> 这使我的主页工作,但标题没有显示它的标题上的“页面未find”。 该页面正在工作,我正在改变的是上面的两个RewriteCond。 他们被设置为{REQUEST_FILENAME}但这使得我的网站主页不工作,并显示默认的服务器页面。
我对apache不是很有经验,但是我已经成功地在我的testing框上运行了以下几个月的设置: me@mydev:/etc/apache2/sites-enabled$ vim 000-default.conf <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 所以基本上,任何时候我在/ var / www / html下创build一个新的文件夹,它都可以在我的浏览器中使用。 但是现在我想尝试做下面的事情: 我创build了一个新的应用程序,具有以下结构: /var/www/html/testrestapp/src/public/index.php 它的工作原理,但我必须导航到: http://localhost/testrestapp/src/public/index.php/hello/sometestname 然后应用程序返回“sometestname” 但我想知道如何configurationApache,以便我可以这样导航: http://localhost/testrestapp/hello/sometestname 并得到相同的结果。 这是我如何修改我的000-default.conf文件(这是启用站点的文件夹中的唯一文件,btw): <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory "/var/www/html/testrestapp/"> RewriteEngine on RewriteBase /testrestapp/ RewriteRule ^src/public/index.php/hello$ hello/ [R] </Directory> </VirtualHost> […]
所以我有这个疯狂的问题发生在apache 2.4 / CentOS7上的一个web应用程序。 我想redirect应用程序域上的所有非安全的URL到安全版本,除了一个uri(供应商沙箱模式的webhook端点 – 没有有效的SSL证书,因为这不是生产,所以我们必须允许http)。 除了应用程序域之外,还有一些客户站点域也贯穿于此,所以我们不希望那些redirect,因为没有SSL,所以我们明确地匹配HTTP_HOST。 这是一个前端控制器模式,我们希望index.php将所有这些请求处理到所有域的非文件和非目录,以及仅通过应用程序域的SSL。 它很简单: RewriteEngine on RewriteBase "/" # Redirect all app domain urls to ssl RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} "^app\.example\.com$" [NC] RewriteCond %{REQUEST_URI} "!^/AllowThisUri/Http" RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # I had to split this -d rule off of the -f rule to account for custom # domain […]
我正在pipe理一个网站tasteporto.com,这是一个简单的PHP / MySQL与WordPress的博客部分。 在主网站上,我有以下的Apache重写规则 RewriteEngine On RewriteBase / # no-www to www RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301] # http to https RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301] # if not blog, make URLs pretty RewriteCond %{REQUEST_URI} !^.*\/blog\/.*$ [NC] RewriteCond %{REQUEST_URI} ^.*\/index [NC] RewriteRule ^(.*)index\.php$ /$1 [R=301,L] # if not blog, make […]
我的网站是非www ,它在子目录中有wordpress,在根目录和其他子目录中有一些静态的网页 我想从根目录中的网页和其他静态网页子目录中删除.html扩展。 最后加斜线。 301使用斜杠从非斜杠redirect到url。 所以应该是 /articles.html 到 / articles / 和 /subdirectory/book.html 到 /子目录/ book / 下面的代码 最后用非斜线工作 使用斜杠将301redirect到非 这是我的.htaccess <IfModule mod_rewrite.c> Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / #removing trailing slash RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ $1 [R=301,L] #www to non RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?domain\.com)$ [NC] RewriteRule .? http://%1%{REQUEST_URI} [R=301,L] #html RewriteCond %{REQUEST_FILENAME} !-f […]
我configuration了Apache Web服务器,它将请求传递给上下文根/ 2d上的Weblogic App Server ProxyPass /2d http://exlhamppatgc.2degreesmobile.co.nz:7003/2d ProxyPassReverse /2d http://exlhamppatgc.2degreesmobile.co.nz:7003/2d 现在我想要从Apache提供静态文件(gif | jpg | png | jpeg | css | js | swf),请先从Apache htdoc文件夹中提供请求。 如果文件不存在,则查找应用程序服务器。
我在每个用户的主文件夹中有两个目录: .html-data和.cgi-bin 。 第一个包含静态(.html)文件,第二个包含dynamic文档生成的文件。 每个用户应该能够发布http://myhost.com/~<username>/上的.html-data文件夹的内容和http://myhost.com/~<username>/上的.cgi-bin文件夹的内容。 http://myhost.com/~<username>/cgi-bin/ 。 创builddynamic内容的脚本应该像提供它们的用户那样执行 (例如~steve/cgi-bin/test.cgi应该以用户steve的forms执行)。 为此,我为Apache 2.4的userdir模块configuration了以下configuration: UserDir .html-data UserDir disabled root <Directory "/home/*/.html-data"> RewriteEngine On RewriteBase /~username/ RewriteRule "^/cgi-bin/(.*)" "../../.cgi-bin/$1" AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS </Directory> <Directory "/home/*/.cgi-bin"> Options ExecCGI SetHandler cgi-script Satisfy any </Directory> 但是,这不起作用。 RewriteRule似乎是错误的。 我怎样才能引用用户的.cgi-bin目录? 这是错误日志: [Thu […]
我有我的.htaccess文件的这个问题。 Google在网站站长工具中有一些我不想要的url(404错误)。 我需要重写包含– , /-或结尾的url,例如: replace–与- 删除-后/ 删除结尾- …但只有当URL不包含product_info.php 。 我尝试过,但它不工作… RewriteCond %{REQUEST_URI} !^/product_info\.php(.*)$ RewriteRule ^(.*)–(.*)$ /$1-$2 [L,R=301] RewriteRule ^(.*)/-(.*)$ /$1/$2 [L,R=301] RewriteRule ^(.*)-$ /$1$2 [L,R=301] 这是一个Magento电子商店与激活清漆caching。 编辑#1: 是的,他们出现在404错误报告! 不工作我的意思是:Magento说:“这个文件已经搬到这里”。 如果我点击那里,有一个“ESI块错误” product_info.php?product=TestProduct–Green–XXL之后可以有东西 在这种情况下,我不想replace– – = – >这是我想的问题。 编辑#2: 这是完整的.htaccess 。 我删除了评论期望redirect我试图得到工作,因为很多的空间。 DirectoryIndex index.php <IfModule mod_php5.c> php_value memory_limit 6144M php_value max_execution_time 18000 php_flag magic_quotes_gpc off php_flag […]
我试图在Ubuntu 15.04上使用mod_rewrite for Apache映射任何URL,例如localhost/first到localhost/first.php 。 这是步骤。 使用(apt-get apache2,php5)安装Apache2,PHP5在Apache中启用PHP,所以phpinfo()打印适当的信息。 a2enmod重写,重启apache 在/etc/apache2/sites-enabled/000-default.conf ,在适当的位置添加以下内容。 <VirtualHost *:80> <Directory /var/www/html> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost> — Restart Apache /var/www/html .htaccess , RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^\.]+)$ $1.php [NC,L] chmod 644 /var/www/html/.htaccess 重新启动Apache 但像/localhost/second这样的请求不会转换为second.php 。 编辑.htaccess ,最后一行改为RewriteRule ^second$ […]