我已经组织了我的巨大.htaccess文件通过redirect永久优先,我想执行,如果发现。 在这种情况下,我不想以后mod_rewrite处理。 有什么办法可以实现吗? 例子: Redirect permanent /products/example.aspx http://www.example.com/products/example/ RewriteCond %{REQUEST_URI} products/([1-9a-zA-Z\s-]+)/ RewriteRule ^products/([0-9a-zA-Z\s-]+)/tutorials(/|\.php)$ /products/$1/help/ [R=permanent,L] 虽然上面没有冲突,我的.htaccess文件是60k大,有一些简单的“redirect永久”似乎被忽略,因为后来的RewriteRules(即redirect模式,而不是)
请帮助。 你能告诉我这是否是正确的代码来执行以下重写? 我无法像我想的那样testing这个特殊的变化。 该公司在一个Apache实例中有四个域。 我只想影响一个 – test.example.com。 我需要这个块来做下面的事情: 如果主机是test.example.com,则任何调用/需要转到/admin/index.php 如果主机是test.example.com,则任何对http的调用都需要转到https RewriteEngine On RewriteBase / RewriteCond%{HTTP_HOST}!^ test \ .example \ .com RewriteRule ^ / admin / index \ .php $ – [L] RewriteCond%{HTTP_HOST}!^ test \ .example \ .com RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d 重写规则。 /admin/index.php [L] RewriteCond%{HTTP_HOST}!^ test \ .example \ .com RewriteCond%{HTTPS}closures RewriteRule(。*)https://%{HTTP_HOST}%{REQUEST_URI} 林恩,非常感谢 更新: 这样的事情呢? RewriteCond%{HTTP_HOST}!^ test […]
我正在尝试设置mod_rewrite以使应用程序的URL更好一些。 我有一个skinnable系统,通过query parameter设置皮肤,所以任何下面的链接将触发一个特定的皮肤加载(并存储为cookie): www.mysite.com/index.html?skin=123 我正在尝试使入口链接进入系统,所以我使用这个: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^/(.*)/$ /index.html?app=%1 [L] </IfModule> 这似乎工作正常,所以我正在加载下列链接正确的页面: www.mysite.com/890/ => www.mysite.com/index.html?skin=890 但是,只有我的初始页面被正确加载,所有CSS和JS文件仍然被请求从错误的pathwww.mysite.com/890/与www.mysite.com 题: 我怎么能重写所有请求的文件(CSS,JS,IMG …)被正确redirect,不包括/890/path? 另外,有没有办法使我的重写更通用,以便我可以处理这两个 www.mysite.com/890/ => www.mysite.com/index.html?skin=890 www.mysite.com/890/foo.html => www.mysite.com/foo.html?skin=890 www.mysite.com/890/bar.html => www.mysite.com/bar.html?skin=890 感谢您的光芒!
我有一个工作RewriteCond喜欢: RequestURL: http ://www.myserver.com/images/gallery/summer/2013/2013-07-07/thumbs/001.jpg RewriteCond %{REQUEST_URI} !images/gallery/summer/2013/* RewriteRule ^images/gallery/summer/(.*)$ http://xyz.s3.amazonaws.com/$1 [P] 这工作正常,图像是从亚马逊S3拉。 但是,为什么在RewriteCond中,RegEx不起作用: RewriteCond %{REQUEST_URI} !^images/gallery/summer/2013/(.*)$ 这只是我想明白为什么上面的代码的作品,其他不? 谢谢
我有我的httpd.conf文件中的以下内容 NameVirtualHost *:80 <IfModule mod_vhost_alias.c> <VirtualHost *:80> ServerAlias * UseCanonicalName Off LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon CustomLog /var/log/httpd/access_log vcommon VirtualDocumentRoot /web-data/vhosts/%0/httpdocs VirtualScriptAlias /web-data/vhosts/%0/httpdocs </VirtualHost> </IfModule> 这对于dynamic托pipe非常有用。 但是,我不知道如何使https请求以相同的方式工作。 我需要添加什么,以便同一个域请求的https和http被发送到同一个文件夹?
我有几个servlet监听内部端口,这些内部端口不能从外部访问。 我使用Apache的ProxyPass和ProxyPassReverse指令从端口443安全地提供服务: ProxyPass /media http://localhost:9002/ ProxyPassReverse /media http://localhost:9002/ 这工作正常 – https://example.com/media从http://localhost:9002/ 。 当URL有不同的部分时,问题就会发生。 例如: https://example.com/image/IMAGE_NAME_1应该从http://localhost:9002/image/IMAGE_NAME_1 。 https://example.com/image/IMAGE_NAME_2应该从http://localhost:9002/image/IMAGE_NAME_1 。 我试过一些变化,包括: RewriteEngine on RewriteRule ^/image/(.*)$ http://localhost:9002/image/$1 [L,PT] ProxyPass /image/ http://localhost:9002/image ProxyPassReverse /image/ http://localhost:9002/image 但是这种configuration导致浏览器中的Bad Request和 Invalid URI in request GET /image/1 HTTP/1.1 在日志中。 如何在代理URL内容各不相同的内部servlet?
我已经设置了一个重写查询string的规则。 尽pipe正确执行了redirect,但URL的重写查询部分会附加%字符,如下所示: 的index.php?选项= com_finder&视图=search&F = 1&ITEMID = 365&Q =在%2520emperor%2527s%2520new%2520school 代替 的index.php?选项= com_finder&视图=search&F = 1&ITEMID = 365&Q =在%20emperor%-27%20new%20school 重写规则设置如下: RewriteCond %{REQUEST_URI} ^/site-search\.html$ RewriteCond %{QUERY_STRING} ^searchword=(.*)$ RewriteRule ^(.*)$ http://www.example.com/index.php?option=com_finder&view=search&f=1&Itemid=365&q=%1 [L,R=301] 我的目标是重写 网站search.html?search内容= someword 如 全站search?Q = someword 语法有什么不对吗?
我有一个网站存储在根文件夹。 example.com正确地把我带到存储在/ var / www / mainsite中的网站。 我想把多个网站放在子文件夹中。 所以example.com/website1,..2,.3等为了做到这一点,我已经使用了一个别名,因为website1没有存储在/ var / www / mainsite中。 Alias /website1 /var/www/website1/public/ 此代码仅适用于主页。 如果我去example.com/website1它正确地加载主页,但如果我访问example.com/website1/css它redirect到example.com/css。 这不应该发生。 任何url我点击子网站或者带我到主网站的404页或主网站上的其他目录,但不是子网站。 我怎样才能停止这样做的Apache。 / var / www / website1 / public中的.htaccess文件为空。 主网站有点.htaccess文件,但由于网站1在不同的文件夹主网站不应该被看着。 我目前正在使用子域,所以即时通讯尝试改变这个使用子目录来代替。 我使用apache和PHP网站的centos 6
我有这个规则: RewriteEngine On RewriteRule ^/page/([a-zA-Z0-9]+)\?(.*)$ /index.php?page=$1&$2 它应该采取这样的事情: /page/contact?cake=lie 并转到页面: /index.php?page=contact&cake=lie 我已经用RegExr和RegexPal等工具testing过了,它在那里工作。 但是当把它放入Apachesconfiguration,访问url给Apaches 404页面。 谁能帮忙?
这是我的Apacheconfiguration(最有趣的部分): <VirtualHost *:80> ServerName example.com … </VirtualHost> 工作正常,我的服务器正确响应example.com:80 HTTP请求。 现在我要添加一个别名到这个域。 我希望所有对my-new-domain.com:80/test请求产生与example.com相同的响应,例如: my-new-domain.com/test/xyz -> example.com/xyz 什么是重要的,我不想看到HTTPredirect(301代码)。 我想隐藏用户的example.com URL。 所有他必须看到的是my-new-domain.com/test URL。