Articles of .htaccess

访问/ app /下的Rails,而不是/ app / public /

我试图用Apache 2.2.10和FastCGI来部署Rails 2.1.2(我知道是的,坏的,古老的,丑陋的)。 我的应用程序可以通过example.com/app/public/访问,但是我想通过example.com/app/访问它。 在我的.htaccess文件(在应用程序/目录!)我有: RewriteEngine On RewriteBase /app/ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ public/dispatch.fcgi [QSA,L] 我怎样才能转发每个请求去app/到app/public/ ? 每次我尝试这个(例如,用RewriteRule ^.*$ public/$1 [QSA] ),我得到一个路由错误: No route matches "/app/" with {:method=>:get} 帮帮我?

所有(子)目录的索引是否相同?

我想知道是否有可能编写一些.htaccess页面,使服务器在一个SINGLE目录中使用index.php文件作为我服务器上每个目录/子目录的索引文件,而不是放置完全相同的索引。在200多个目录中的PHP。 如果我的描述不清楚,我的意思是:/files/index.php被用作例如/ files / morefiles的索引,以及所有目录和子目录的索引/ files /,尽pipe这些目录本身没有索引文件。 感谢所有提前。 编辑:PHP文件根据目录生成不同的输出; 具体来说,如果设置了某个cookie,它会列出当前目录的内容。 所以,不幸的是,URL重写将无法正常工作。

redirectWeb子文件夹根(/文件夹到/)

我试图redirect/文件夹/使用.htaccess但我所得到的是Apache HTTP服务器testing页。 我的根目录如下所示: / .htaccess -/folder -/folder2 -/folder3 我的.htaccess看起来像这样: RewriteEngine On RewriteCond %{REQUEST_URI} !^/folder/ RewriteRule (.*) /folder/$1 我究竟做错了什么? 我检查了我的httpd.conf(我正在运行Centos)和mod_rewrite库正在加载。 作为一个方面说明,我的服务器不是一个万维网服务器,它只是一个虚拟机,所以它的主机名是centosvm。 另外:我的httpd.conf看起来像这样: <VirtualHost *:80> ServerName taa.local DocumentRoot /var/www/html SetEnv APPLICATION_ENV "dev" Alias /taa /var/www/html/taa/public <Directory /var/www/html/taa/public> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>

为不同的子目录提供一组特定的错误页面

我目前正在尝试为网站中的单独文件夹设置两组不同的错误文档。 我有一个网站的根目录中的2个文件夹: demo/ live/ 任何在demo文件夹中返回404或403的请求都需要为Apache errordocument加载一组页面,例如。 ErrorDocument 404 /statuses/demo-404.html ErrorDocument 403 /statuses/demo-403.html 而现场需要去类似的名字文件。 ErrorDocument 404 /statuses/live-404.html ErrorDocument 403 /statuses/live-403.html 到目前为止,我已经尝试将.htaccess文件放置在这两个目录中,并将ErrorDocument指令设置指向特定的文件,404工作正常,并引用正确的页面。 但是,当尝试访问demo目录中的禁止文件夹时,403s不工作并且恢复到服务器默认值,日志显示如下: [Wed Jun 16 04:47:44 2010] [crit] [client 115.64.131.144] (13)Permission denied: /home/abstract/public_html/demo/xxx/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable 它是否正确? 将Apache恢复默认,因为它试图寻找一个文件夹中没有权限的htaccess? 为什么它不能通过文件夹树的方式? 我可以做到这一点吗?

为什么PHP不能从别名目录运行?

我正在尝试使用nclud的windex风格化我的apache目录列表为一个内部项目(安全性不是太多的关注) Windex使用指向PHP文件的HeaderName和ReadmeName指令,只要windex php文件位于VirtualHost所在的目录中,Windex就可以工作。 但是,我想在/ usr / share / windex中进行标准安装,原因有两个。 首先是我不希望Windex文件夹出现在列表中。 第二个是我想在多个虚拟主机上使用它,然后修改它。 所以.htaccess文件保留在我的/ srv / www目录中。 在我的虚拟主机的httpd.conf中,我指定了一个别名: Alias /windex/ "/usr/share/windex" <Directory "/windex"> Options Indexes,FollowSymlinks AllowOveride All Order Allow,Deny Allow from all </Directory> <Directory "/usr/share/windex"> Options Indexes,FollowSymlinks AllowOveride All Order Allow,Deny Allow from all </Directory> 现在这适用于/ windex / icons / *和/ windex / css /中的图像和css文件。所有样式都正确应用。 但是,PHP文件没有得到处理。 但是,如果我浏览到/windex/header.php文件,文件是由PHP正确处理的。 […]

使用htaccess从远程服务器提供文件

有没有可能使用htaccess来做到这一点? 用户访问 – > http:// mydomaina.com/dir/filename 它将显示 – > http:// mymainsite.com/anydir/mydomaina-filename的内容 我有一个htaccess的代码,但它不能正常工作,可能是缺less的东西 <IfModule mod_rewrite.c> RewriteRule ^dir/(.*)\.xml$ http://mymainsite.com/dir/%{HTTP_HOST}-$1.xml [P] </IfModule> 谢谢

将旧的.htaccess规则转换为IIS重写规则

我已经开始在IIS上托pipe我自己的站点,它以前在Apache上的DreamHost上托pipe,所以我有一个带有重写规则的.htaccess文件,我想将其转换为URL重写模块规则。 # initialize mod_rewrite RewriteEngine on RewriteBase / # remove the www from the url # RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] # RewriteRule ^(.*)$ http://%1/$1 [R=301,L] ### BEGIN GENERATED REWRITE RULES #### RewriteCond %{REQUEST_FILENAME}/index.html -f RewriteRule ^(.*) $1/index.html #### END GENERATED REWRITE RULES #### # listing pages whose names are the same as their enclosing folder's […]

重写规则的apache错误日志

我正在下面的错误在Apache日志 文件不存在:D:/ wamp / www / script / products,referer: http://localhost/script/products/category/product-123.html每当跟随url localhost / script / products / category / product-123。 html是通过这个重写规则来parsing的。RewriteRule ^ products /([〜A-Za-z0-9 – “] +)/([〜A-Za-z0-9 – ”。+)。html $ index.php? page_type = products&prod = $ 2 [L]。 脚本和规则工作正常,但我得到的错误在Apache错误日志。 我已经激活了RewriteLog,但在rewrite.log文件中没有显示出来。 它是空的。 请提前帮助和感谢。

Linux使用.htaccess将wwwredirect到非www

我正在尝试使用我的根目录中的.htaccess文件将www.example.comredirect到http://example.com 。 我已经尝试了这里和其他地方列出的例子。 rewriteengine打开。 rewriteCond %{HTTP_HOST} ^www\.(.*) [NC] rewriteRule (.*) //%1/$1 [L,R=301] 我已经在我的.htaccess文件的不同位置插入了这一点,我得到redirect错误,说这是错误的redirect。 在上面的例子中,我是否需要在某处插入我的实际网站信息? 如果是这样,有人可以给我一个例子使用www.example.com ? 我在一台基于Linux的服务器上,通过GoDaddy。

在符号目录上的urlrewrite htaccess

我有一个使用htaccess url重写符号文件夹的问题。 下面是我在htaccess文件中用于URL重写的行。 RewriteRule ^global/css/([0-9]+)/([az-_]+)\.css$ global/less/index.php?site_id=$1&file=$2 [L] “全球”是我的象征目录 这个规则工作正常,当我在其他符号目录上使用它。 但它在符号目录上不起作用。 它正在我的现场服务器上工作,但不能在我的本地testing服务器上工作。 需要其他configuration才能使其工作。 任何解决scheme