我有一个在cpanel之前的子域设置(sub.domain.comredirect到domain.com/sub/),突然间我今天突然发现它是在浏览器中重写URL到www.domain.com/sub/,而不是只是把它留在sub.domain.com。 我不知道是什么问题,但决定删除我的子域,并在cPanel重新创build它。 现在我只能访问www.sub.domain.com(sub.domain.com产生一个服务器没有find错误)。 编辑:问题似乎与.htaccess文件。 删除后,事情恢复正常。 但是现在我的新问题是如何正确configuration.htaccess文件。 我最初调整了它,试图完成以下内容: 我有三个文件夹,live,staging和dev: 1)domain.com或www.domain.com的请求被定向到domain.com/live(并且用户看到的URL总是被重写为www.domain.com)。 2)请求staging.domain.com和dev.domain.com或分别定向到domain.com/staging和domain.com/dev,并且用户在浏览器中看到staging.domain.com或dev.domain.com 。 3)当我将其添加到cPanel中时,任何子域通常都不会被浏览器重写。 我当前的.htaccess文件完成数字1很好,但重写staging.domain.com到www.domain.com/staging等等。 RewriteCond %{HTTP_HOST} !^www\.domain\.com$ RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] RewriteRule ^$ /index.html RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !\..+$ RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://www.domain.com/$1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/live/ RewriteRule ^(.*)$ /live/$1
我在我的Apache服务器上有以下目录: root/dir1/ root/dir2/ root/dir3/… 是否有可能使我的子目录(dir1,dir2,dir3)的内容“好像”直接在root/ ? 我正在寻找一个dynamic创build的目录解决scheme。
我正在尝试重写我的url的子域名。 http:// username .domain.com将显示http://www.domain.com/user.php?u= 用户名的内容,但URL保留为http:// username .domain.com。 (我的意思是url掩盖 ) (用户名可以包含az 0-9和超级) 同样,如果subdomain是www或api ,不要redirect它们 我用我的.htaccess RewriteEngine on RewriteCond %{REQUEST_URI} !^/index\.php$ RewriteCond %{HTTP_HOST} !^www\.domain\.com RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com RewriteRule .* /user.php?u=%1 [L] (在@ mfarver的build议之后)我正在尝试这个 RewriteEngine on RewriteRule .* /user.php?u=%1 [L] 但是这次得到500内部服务器错误: [Mon May 30 20:10:44 2011] [alert] [client 81.6.xx.xxx] /home/blablabla/public_html/.htaccess: AllowOverride not allowed here (来自错误日志) 我的服务器的httpd.conf文件的虚拟主机设置 <VirtualHost 109.73.70.169:80> […]
我试图得到一个简单的万维网。 到非www。 redirect设置。 这是.htaccess DirectoryIndex index.php RewriteEngine On RewriteCond %{HTTP_HOST} ^www.domain.org [NC] RewriteRule ^(.*)$ http://domain.org/$1 [L,R=301] RewriteBase / ########## Begin – Rewrite rules to block out some common exploits ## If you experience problems on your site block out the operations listed below ## This attempts to block the most common type of exploit `attempts` […]
我试图编写一个自定义的redirect规则为2testing目的完全相同的网站。 我使用的代码是: RewriteEngine on RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4$ RewriteCond %{HTTP_HOST} ^.*site1.com [NC] RewriteRule ^(.*)$ http://www.site2.com/$1 [R=301,L] 我想要的是将所有请求的site1redirect到site2,除了来自IP地址1.2.3.4的请求。 但目前来自该IP的请求也正被redirect到site2。 有什么我错过了设置? (注意:两个域名都在同一个共享主机帐户上) 编辑:我也尝试过: RewriteEngine on RewriteCond %{REMOTE_ADDR} !^my_ip$ [OR] RewriteCond %{REMOTE_ADDR} !^server_ip$ RewriteCond %{HTTP_HOST} ^.*site1 [NC] RewriteRule ^(.*)$ http://site2/$1 [R=301,L] RewriteEngine on RewriteCond %{REMOTE_ADDR} !=my_ip [OR] RewriteCond %{REMOTE_ADDR} !=server_ip RewriteCond %{HTTP_HOST} ^.*site1 [NC] RewriteRule ^(.*)$ http://site2/$1 [R=301,L] RewriteEngine […]
我的一个网站最近被黑了。 为了简短起见,我有一个老版本的wisiya新闻快讯,用来上传wp-content目录中的几个文件。 从那以后,这个领域的安全性发生了很大的变化。 除此之外,我通过.htaccess实现了一个全球性的阻止wp-login.php,如下所示: <Files wp-login.php> Order deny,allow Deny from all Allow from my.own.static.ip.adress </Files> 我比较了这个变化实施之前和之后的访问日志,并对结果感到满意。 所有未经授权的访问尝试都被403响应阻止。 直到今天…. Sucuri通过电子邮件告诉我,有人必须获得访问login表单,并已发送一个单一的login请求到服务器。 IP Address: 192.96.204.237 Notification: User authentication failed: admin 这是我改变.htaccess文件后…因为我仍然是相当新的一般的Apache和安全,有人可以向我解释这是甚至可能吗? 亲切的问候,迈克尔
我正在尝试将domain.comredirect到domain.se/en ,但它不起作用。 这就像另一个重写或redirect发生在domain.se/sv 之前,我有机会 。 我试过多个VirtualHostsconfiguration和.htaccess变种没有成功。 domain.com使用指向与domain.se (主域)相同的IP的Alogging。 我怀疑WordPress插件Polylang可能会重写URL或导致redirect,然后我有机会。 我的.htacces目前看起来像这样: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} .*domain.com.*$ RewriteRule ^(.*)$ http://domain.se/en [L] </IfModule> # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress 和我的VirtualHostsconfiguration看起来像这样:(注意.no和.fi也错误地redirect到.se/sv ) NameVirtualHost *:80 […]
我有两个url。 一个看起来像这样(这是一个不重写的URL): www.example.com/article.php?id=12 下一个是这样的(这是一个重写的URL): www.example.com/article/12 这两个url正在工作。 我想知道的是,如果用户访问第一个URL,他会自动redirect到第二个URL? 我怎样才能做到这一点? 有没有办法做同样的只使用.htaccess文件? 也请帮助,如果我想包括标题也与我这个丑陋的url将看起来像这样。 www.example.com/article.php?id=12&title=sometitle 预计漂亮的url是这样的 www.example.com/article/12/sometitle 我正在使用的redirect规则是这样的 RewriteRule ^article/(\d+)/([\w-]+)$ article.php?id=$1&title=$2[R=302,L] 即使他访问丑陋的网页,我也不希望用户看到丑陋的url。
任何人都可以指导我如何限制可以从目录列表中的Apache下载的文件types? 我在httpd.conf中有一些目录定义,如下所示: <Directory "/var/www/data01"> Options Indexes FollowSymLinks Require all granted AllowOverride none </Directory> 我想让用户做的是列出每个文件夹中的所有文件,但只下载具有特定扩展名的文件(例如* .txt) 我试过这个: <Directory "/var/www/data01"> Options Indexes FollowSymLinks IndexOptions ShowForbidden Require all granted AllowOverride all order allow,deny <FilesMatch "\.txt$"> order deny,allow allow from all </FilesMatch> </Directory> 但是,当我浏览文件夹时,这给了我一个'您没有权限访问'的错误。
我正在使用的软件使用丑陋的url。 为了方便用户共享项目(这是一个项目pipe理包),我想要redirect。 它应该redirectprojectadmin.dev/project/1234到其他的URL。 我可以得到这个使用他们的web.config文件ISS的工作,但Apache让我头痛。 为了演示目的,我缩短了我当前的.htaccess文件,但它仍然给出了这个问题: RewriteEngine On RewriteRule ^.*project/([0-9]+)$ RandomOtherPage.php 当我访问urlprojectadmin.dev/project/123它给了我一个403(禁止)的错误。 我认为这是因为文件夹project存在于我的项目中。 当我将.htaccess文件更改为: RewriteEngine On RewriteRule ^.*projects/([0-9]+)$ RandomOtherPage.php 并去projectadmin.dev/projects/123它将按我的意图工作。 我的问题:我如何忽略项目文件夹存在的事实,但仍然有可访问的文件(例如projectadmin.dev/projects/image.jpg仍然可以工作),并有数字工作redirect?