如果在主目录中不存在index.html或index.php文件,是否可以将(通过Rewrite Cond?)用户redirect到另一个URL以获得帮助? 感谢Greg
我想访问domain.com/api/(.*)而不是domain.com/public/api/(.*) 目录结构: domain.com __folder1 __folder2 __public ____api ______.htaccess2 ____afolder1 ____afolder2 ____index.html __folder3 __file1 __file2 __.htaccess1 .htaccess1 RewriteEngine on SetEnv APPLICATION_ENV production RewriteRule ^$ /public/ [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/public/ RewriteCond %{REQUEST_URI} !^/api/ RewriteRule ^(.*)$ /public/$1 [L] .htaccess2 RewriteEngine on SetEnv APPLICATION_ENV production RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ […]
我正在尝试使用.htaccess将我网站上的一个页面redirect到https对应的页面。 checkout.php页面位于网站的根目录/ html文件夹中。 (/checkout.php)。 我试过使用这个:(我在网上find的地方)。 我把它,并得到了内部服务器错误。 RewriteEngine On RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !checkout.php RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 这个想法是,如果一个客户在checkout.php页面,然后redirect到https …如果他们不是,redirect到http。 任何帮助都是极好的。
我已经在依赖.htaccess重写规则的子文件夹中安装了脚本 – 如果您在正确安装后访问脚本,它将redirect到您实际上不存在于服务器上的/login页面。 然而,这一切都在Apache上。 我想知道如何将下面的.htaccess规则转换为nginx,但也不会影响我们的网站在根目录中。 .htaccess读取… Options +FollowSymLinks IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php 该脚本在一个子文件夹中 /clp2/ 所以我假设如果我做任何redirect的位置规则,它将需要指定子文件夹? 由于这个.htaccess文件显然是文件夹特定的,而不是networking特定的。 脚本的完整服务器path是 /var/www/vhosts/i-16852366/clp2 任何input的欢迎,我认为这是很容易,如果你知道你在做什么 – 我试过一个nginx重写器,但它不工作,显然不是特定于我需要它做重写规则的文件夹,所以我也需要一些指导。 这里是我目前的nginx.conf – 我假设它会在http块的某个地方? user nginx; worker_processes 2; error_log […]
我有一个运行在Apache服务器上的旧网站,它已经在Google中被编入索引。 我希望将所有这些索引链接redirect到我的新网站(因为较旧的页面不再存在)。 所以我希望将我的所有子子页面redirect到新的根页面 我有如下页面 http://itdost.com/answer-now/Aerobics http://itdost.com/answer-now/HTML http://itdost.com/answer-now/Culture 我为每一个使用下面的redirect代码 Redirect 301 /answer-now/Engineering http://www.itdost.com/questions/ Redirect 301 /answer-now/Food http://www.itdost.com/questions/ Redirect 301 /answer-now/ASP http://www.itdost.com/questions/ 但是,由于网站结构很大,我希望在一行中完成,而不是为每个redirect写一行 有些事情如下。 Redirect 301 /answer-now/% http://www.itdost.com/questions/ 但是上面的代码似乎不起作用
我有很多redirect工作,但我有一个需要redirect,并删除文件名。 redirect 301 /path/to/file/default.aspx http://www.domain.com/newpath/to/page/ 当我实现它时,它会尝试redirect,但不会从URL中删除default.aspx。 编辑 重写规则: ## path relative to web root RewriteBase / ## workaround for HTTP authorization ## in CGI environment RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] ## always send 404 on missing files in these folders RewriteCond %{REQUEST_URI} !^/(media|skin|js)/ ## never rewrite for existing files, directories and links RewriteCond %{REQUEST_FILENAME} !-f RewriteCond […]
我有一个网站,这是基于一个search页面,显示一个列表,接下来是一个细节页面的项目。 如果访问者使用rootdomain.com/searchterm ,应将其redirect到rootdomain.com/index.php?keyword=searchterm 。 我现在正在工作的细节rootdomain.com/detail/productname ,应该redirect到rootdomain.com/detail.php?name=productname 在这里我失败了 我一直使用我的$ 1作为“detail / productname”redirect到index.php, 这是我的.htacces到目前为止: RewriteEngine on RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/detail/(.*)$ detail.php?name=$1 [L,QSA] -> L here doesn't work either. RewriteRule ^(.*)$ index.php?keyword=$1 [L,QSA] 更新 好的,我现在非常接近 问题是重写条件只对下一条规则有效,所以我必须重复一遍,我也在第一个条件中添加了ignore detail.php,因为我的redirect已经被redirect到索引。 现在由于某种原因,我的条件为-F似乎不能在细节/我所有的CSS和图像不工作。 排除他们的最好方法是什么? RewriteEngine on RewriteCond $1 !^(index\.php|detail\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule […]
我找不到任何问题。 附录00-default AccessFileName .htaccess Alias /api "/var/www/AppServices/public" Alias /server_api "/var/www/AppServices/Server_API" Alias /client_api "/var/www/AppServices/Client_API" Alias /secure_api "/var/www/AppServices/Secure_API" Listen 8002 <VirtualHost *:8002> DocumentRoot /var/www/AppServices/public ServerName .local # This should be omitted in the production environment SetEnv APPLICATION_ENV development <Directory "/var/www/AppServices/public"> Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost> 的.htaccess <IfModule mod_rewrite.c> RewriteEngine […]
我在我的.htaccess文件中使用下面的。 有3种types的redirect: redirect到目录/admin/index.php redirect到特定的.php文件,例如/ about redirect到/ John的用户个人资料页面 所有3个工作在我的本地环境,但在服务器上只有1和3的作品。 我真的很感激,如果你能告诉我为什么URLredirecttypes“/约”不适合我。 非常感谢。 <IfModule mod_rewrite.c> Options -Multiviews Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^admin$ /admin/index.php [QSA,L] RewriteRule ^about/?$ /about.php [NC,L] RewriteRule ^es/?$ /index.php?lang=2 [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([_A-Z0-9a-z-+\.]+)/?$ /public_profile.php?id=$1 [L] </IfModule> ErrorDocument 404 /404.php
所以这个想法是我有: domain.com/.subdomains/domain1 (2,3,4,etc) 而我想映射: domain1.domain.com -> domain.com/.subdomains/domain1/ domain2.domain.com -> domain.com/.subdomains/domain2/ 但是我希望它忽略“www” 我这样做是半成功的: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com [NC] RewriteRule ^(.*)$ http://domain.com/.subdomains/%1/$1 [NC,QSA,L,P] 有两个问题: 1)它不会忽略“www” 2)当我去到URL: http://domain3.domain.com/deep/subfolder/here/index.html 它将我redirect到: http://domain.com/.subdomains/domain3/deep/subfolder/here/index.html 我一直在试图find答案,但我找不到任何其他人有这个问题。 有任何想法吗? 谢谢! 编辑: 好吧,似乎我不能使用http,但如果我改变 RewriteRule ^(.*)$ http://domain.com/.subdomains/%1/$1 [NC,QSA,L,P] 至 RewriteRule ^(.*)$ /.subdomains/%1/$1 [NC,QSA,L,P] 它进入一个奇怪的redirect循环