我试图禁止访问任何与wordpress相关的内容 下面的不起作用,只是发射一个404: RewriteRule ^(.*wp-.*)$ – [L,F] 虽然如果我这样做,一切都很好: RewriteRule ^(.*wp-.*)$ whatever [L,R] 编辑:通过http://htaccess.madewithlove.be/检查显示没有问题。 编辑2:我看不出这是如何重复的mod_rewrite啧啧,显然我已经检查了它,不幸的是没有find解决办法。 编辑3:我能够确认它可以在我的本地虚拟机和其他临时服务器上工作,有没有办法在生产服务器上进行debugging? 编辑4:在评论中提供了修复,清楚地显示该解决scheme没有在“重复”的职位中提到,但是与默认的403错误页面丢失
我试图通过结合一些.htaccess规则来设置通配符子域RewriteRule ,因为我相信我可以对我的Apache vhosts文件使用相同的规则。 实质上, example.com和www.example.com转到根path并查找index.php 。 所有其他(dynamic)子级别的请求,例如abc.example.com被重写(浏览器不可见)到example.com/process.php?p=abc 。 其次,基本/根级别之外的任何来自子域的文件的请求需要被重写为从没有子域的标准域的根path获得。 所以abc.example.com/css/style.css需要来自example.com/css/style.css 这是我的尝试。 我得到一个Apache错误: 您无权访问此服务器上的/index.php。 对于任何子域的尝试,除了www,其预期的工作,以及标准的example.com ,仍然工作正常。 <VirtualHost *:80> ServerAdmin [email protected] ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] ServerName other.example.com ServerAlias *.example.com DocumentRoot /var/www/example.com/public_html/ <Directory /var/www/example.com/public_html/> Options FollowSymLinks AllowOverride all Require all granted RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteCond […]
我对.htaccess挺.htaccess而我只是没有深入了解发生了什么事情。 服务器只是说,即使我看不到任何理由“redirect”,超过了10个内部redirect的限制。 它只发生在我尝试使用/users/Username , /users/显示一个错误,该用户无法find这是我想要的, /users/Username引发500内部服务器错误。 文件本身是好的,数据库检查也应该工作。 .htaccess文件是: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.php [L] IndexIgnore * ErrorDocument 400 / ErrorDocument 404 / RewriteRule ^users/([a-zA-Z0-9_-]+)/?$ users.php?id=$1 [NC,L]
我必须将移动用户redirect到一个新的URL( /amp/… ),所以我将这个片段代码添加到我的Apache站点configuration: RewriteCond %{HTTP_REFERER} !^http://test.domain.com [NC] RewriteCond %{REQUEST_URI} !^/amp/.*$ RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC] RewriteRule ^(.*)$ /amp/$1 [L,R=302]` 问题是我只在请求主页时( test.domain.com )redirect,而不是当我请求任何其他URL(例如test.domain.com/category/web )。 任何想法我做错了什么? 这是一个WordPress的网站,完整的重写模块是: <Directory /var/www/project> DirectoryIndex index.php Options None FollowSymLinks AllowOverride none <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^uploads/(.+) http://myCDN.com/uploads/$1 [R,L] RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule […]
我尝试将所有的urlredirect到除了wordpresspipe理和wordpress REST API之外的根目录。 我在.htaccess有这些规则: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/wp-admin.* RewriteCond %{REQUEST_URI} !^/wp-json.* RewriteRule ^.*$ / [L,R=301] </IfModule> 这是完美的工作,所有的redirect期望的/wp-json路线,我得到404错误。 此外,我有我的apache日志文件中的这些错误types: File does not exist: […]/dmjob/wp-json, referer: http://dmjob.dev:8888/ 你能帮我么 ? 非常感谢 ! 🙂
全新的.htaccess和我已经阅读howto的几个星期,随着负载的实验。 我迫切需要一个人来看待我的事情,告诉我是否有任何错误或只是简单的不会工作:)这里是: 我认为这是重复的,可以或应该结合,但我不知道如何去做。 AddHandler的东西是一些PHP网站的问题,我有,命令允许拒绝尝试阻止链接从坏的网站,所有的重写是第二次尝试在块所有除了一些是好的。 这几个星期拼凑在一起,所以我不怀疑我在某个地方弄错了。 任何帮助将是伟大的。 提前致谢。 <AddHandler server-parsed .htm AddHandler server-parsed .html Addhandler application/x-httpd-php .html .php> <order allow,deny allow from all deny from *.ru deny from tamanria.com> <RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?ceplocal2003.org(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?yellowpages.ca(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?cep.ca(/)?.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://(www\.)?goldbook.ca(/)?.*$ [NC] RewriteRule .*\.(gif|jpg|jpeg|bmp|png|pdf)$ http://www.ceplocal2003.org/images/Refererblock.gef [R,NC]> <RewriteEngine on […]
这是一个屁股问题的痛苦! 天才解决这个谜语将获得贝宝捐赠吃两个晚餐。 现在让我们开始吧。 鉴于:大多数代理,不要caching资源与“?” 即使在响应中存在Cache-control:public头部,它们的URL也是如此。 要为这些资源启用代理caching,我必须从对静态资源的引用中删除查询string,而不是将参数编码到文件名称中。 以前有过 <img src="/imgcpu?src=folder1/photo_citty.jpg&w=3500&h=10&c=p&q=90" /> <img src="/imgcpu?src=folder2/photo_doggy.jpg&w=100&h=200&c=p" /> <img src="/imgcpu?src=folder3/photo_birds.jpg&w=200&h=500&f=bw" /> <img src="/imgcpu?src=folder3/photo_frogs.jpg&h=200" /> 工作中 <img src"/IMG-folder/photo_w100_h100_cf_q60.jpg"/> 图像将驻留在根目录下的1个文件夹中(永远不会更深) img.php?src =或者img?src =将永远被永远命名 在…. jpg&w,&h,&q,&m,&f和&c是调用variables的唯一字母(例如:&w = 200&h&= 50&c = p&f = bw&q = 90) 在这个不雅的代码的成本 # Rewrite imgcpu?src= thumbnail maker to nice static urls RewriteCond %{REQUEST_URI} ^IMG.*$ RewriteRule ^IMG-(.+)_w(.+)_h(.+)_c(.+)_q(.+).jpg$ imgcpu\?src=$1\.jpg&w=$2&h=$3&c=$4&q=$5 [L] RewriteRule […]
我正在尝试为几个根域设置redirect。 首先,这是我的httpd-vhosts.conf文件中的代码: <VirtualHost *:80> ServerAdmin ****@example.com ServerName example.com ServerAlias example2.com RewriteEngine On RewriteCond %{HTTP_HOST} !^192\.168\.0\.1$ # This is our WAN IP RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE] </VirtualHost> 这样做是将example.com或example2.com的根域或www以外的任何主机redirect到www.example.com(2).com 我遇到问题的部分是RewriteRule本身。 $ 1应该与RewriteRule的模式相匹配,并将其添加到replace中。 例如:“ http://example.com/test.html ”应该重写为“ http://www.example.com/test.html ” 它适用于所有现代浏览器,除了IE8或IE9外(我没有testing其他IE版本)。 在IE中,这是有效的:“ http://example.com ”为“ http://www.example.com ” 在IE中,这是行不通的:“ http://example.com/test.html ”到“ http://www.example.com/test.html ” 有没有人有这种行为的解释? 我希望我已经解释得很好。 […]
我想根据他们的user_agent检测移动用户。 如果用户正在浏览网站的完整版本,并且他们有一个特定的user_agent,我想将他们(使用mod_rewrite)redirect到移动网站 – 如果移动页面存在。 完整网站url示例http://www.domain.com/page1.html等效移动网站url示例(注意.htm而不是.html) http://m.domain.com/page1.htm 我需要用Apache来做这个,而不是像PHP一样 奖励:移动网站可以链接到整个网站(如果页面没有移动equilelant),我想继续redirect人,我想继续redirect,除非用户点击“完整站点”链接,这将select他们通过url参数redirect – 例如:?ver = ful
我想获得以下的Apacheredirect工作: 当有人冲向mydomain.tld/contact ,他们应该被redirect到mydomain.tld/#contact 。 这是因为我用自动滚动build立了一个单页的网站。 这不工作: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php#$1 – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> 谢谢!