我在Linux Mint发行版上运行Apache 2.2.20时遇到问题。 我的.htaccess文件中有以下规则: RewriteEngine on RewriteRule old1/old2 http://localhost/new1 [P] 当我浏览到http://localhost/old1/old2我只是redirect到localhost/new1 。 也就是说,新的URL显示在地址栏中。 我想显示“old1 / old2”的url(来自/ new1的网页内容)。 我究竟做错了什么? 我已经安装了mod_proxy和mod_proxy_http(即a2enmod proxy , a2enmod proxy_http )。
所以我想重写下面的url结构 mysite.com/cgi-bin/shop/shop.cgi/ 至 mysite.com/+ 我有这个作为一个规则,它的工作原理,但它不强制url打印在浏览器中,当你仍然指向旧的url。 所以我有重复的内容。 我已经尝试添加[R = 302],它不起作用。 [R = 302]使它打印出原来的旧url结构(/cgi-bin/shop/shop.cgi/%)。 有任何想法吗? RewriteRule ^\+([^*]+)/?$ /cgi-bin/shop/shop.cgi/$1 任何帮助将不胜感激!
我正在GitList (Git的PHP web浏览器)和GIT智能HTTP(S)在同一域git.domain.ext下。 以下是实际设置: GIT智能HTTPurl格式为git.domain.ext / git / reponame.git GitList通过git.domain.ext / gitlist来提供 到现在为止还挺好。 一切正常。 我想达到的是以下几点: 任何forms的git.domain.ext / *。git的请求应该改为git.domain.ext / git / *。git 任何其他请求应该默认为git.domain.ext / gitlist 以下是我的Apacheconfiguration: <VirtualHost *:443> ServerName git.domain.ext DocumentRoot /home/user/www/git.domain.ext SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER SetEnv GIT_PROJECT_ROOT /home/user/git/ SetEnv GIT_HTTP_EXPORT_ALL ScriptAlias /git/ /usr/lib/git-core/git-http-backend/ <Location /> AuthName "Git Authentication" AuthType Basic Require valid-user AuthUserFile /home/user/git/.htpasswd </Location> <LocationMatch […]
我试图限制访问某些目录到某些IP ….我已经做了一些研究,下面是我想出来的,但是当我尝试访问页面时,它返回一个500内部服务器错误.. <Directory "/home/username/public_html/admin/"> order deny,allow deny from all allow from 123.45.67.89 allow from 111.222.333.444 allow from 123.45.*.* allow from 123.44.*.* </Directory> <Directory "/home/username/public_html/blog/wp-admin/"> order deny,allow deny from all allow from 123.45.67.89 allow from 111.222.333.444 allow from 123.45.*.* allow from 123.44.*.* </Directory> 我做错了什么!?
我的情况如下:我有我的本地服务器上的public/文件夹中的静态文件。 任何进来的请求应该被转发到该文件夹,但是如果该文件夹中的文件被直接访问,它应该是404或redirect到'slug'。 例: Request: /my-file Should rewrite to: /public/my-file.html URL should be: http://localhost/my-file Request: /public/my-file.html Should rewrite to: /public/my-file.html URL should be: http://localhost/my-file 我在.htaccess有以下规则和条件: RewriteCond %{DOCUMENT_ROOT}/public/%{REQUEST_URI}.html -f RewriteRule ^.*$ /public/$0.html [L,C] RewriteCond %{REQUEST_URI} ^/public RewriteRule ^public/(.+).html$ /$1 [R=301,L] 从上到下: /public/{request}.html文件是? 如果(1)为真,则重写:/ /public/{request}.html ,并链接到(3)以防止redirect循环 原始请求是以/public开头的吗? 如果(3)为真,并且原始请求匹配public/{request}.html : /{request} ,则重写。 另外制作一个301头,告诉我的浏览器和抓取工具页面已经永久移动了。 请求将再次贯穿所有规则 所以,如果我们做了这两个要求: 1. Request: /my-file /public/my-file.html计算结果为true; […]
我试图使用mod_rewrite基本上端口转发到另一个IP上的另一个端口的子域上的端口。 喜欢这个: sub.website.com:2000 –> 123.45.67.891:3000 这怎么可以使用mod_rewrite使用.htaccess文件? 我尝试了以下,但无济于事: RewriteCond %{HTTP_HOST} ^sub.website.com$ [NC] RewriteCond %{SERVER_PORT} ^2000$ RewriteRule ^(.*)$ https://123.45.67.891:3000/$1 [L,R=302]
简单的问题真的。 内部redirect后,原来的“上下文”消失了。 我想知道是否有一个variables或标志,让我检查原来的请求,而不是重写的请求。 伪代码: RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .+ public/$0.html [L] RewriteCond %{WHAT_USER_TYPED} ^public/(.+)\.html RewriteRule .+ – [R=404,L] 在这个例子中,当我键入mywebsite.com/slug ,请求被重写为path public/slug.html 。 现在,发生内部redirect,我的path可能匹配第二个条件public/(.+)\.html ,并返回一个404.这不是我想要的。 所以,我想知道是否有这样的解决scheme。
我运行8-10个基于EC2的Web服务器,所以我的经验是很多小时,但仅限于CentOS; 特别是亚马逊的分销。 我正在使用yum安装Apache,因此获得了Amazon的默认编译Apache。 我想要使用mod_rewrite实现从非www(bare / root)域的规范redirect到www.domain.com的search引擎优化,但是我的.htaccess文件一致地忽略了。 我的故障排除步骤(下面概述)使我相信这是亚马逊构buildApache的特定事件。 testing用例 启动EC2实例,例如Amazon Linux AMI 2013.03.1 SSH到服务器 运行命令: $ sudo yum install httpd $ sudo apachectl start $ sudo vi /etc/httpd/conf/httpd.conf $ sudo apachectl restart $ sudo vi /var/www/html/.htaccess 在httpd.conf中,我更改了以下内容,在DOCROOT部分/范围中: AllowOverride All 在.htaccess中,补充说: (编辑,我后来添加了RewriteEngine On ) RewriteCond %{HTTP_HOST} ^domain\.com$ [NC] RewriteRule ^/(.*) http://www.domain.com/$1 [R=301,L] .htaccess上的权限是正确的,AFAI可以告诉: $ ls -al /var/www/html/.htaccess […]
我正在尝试为我的网站设置一个自己托pipe的cdn,但是我在htaccess文件中遇到了一些问题,并且无法使其工作。 目前,作为CDN的ftp服务器具有以下文件系统结构: / www/ www/htaccess www/index.html www/cdn/* incremental/* full/* 我的.htaccess现在看起来像这样: Options All -Indexes <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] </IfModule> #This snippet basically stops anyone viewing any file on your site that begins with "hta", this will protect it and make it somewhat safer. <Files […]
我试图configuration我的.htaccessredirect到根目录的所有txt文件到404错误。 (除robots.txt外) 我尝试使用RedirectMatch 404 [^robots]\.txt$但它也redirect我的子目录上的txt文件。 谢谢。