我有一个反向代理规则,将所有请求转发到一个特定的子域到内部服务器,一切都很好。 <rule name="cloud.domain.com" enabled="true" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="^(cloud.)domain.com$" /> </conditions> <action type="Rewrite" url="http://127.0.0.1:8000/{R:0}" appendQueryString="true" /> </rule> 这适用于cloud.domain.com的http和https请求。 但是,我希望所有的请求http://cloud.domain.com转发到https://cloud.domain.com哪些做反向代理到内部服务器。 有任何想法吗?
我在网站上更改了类别url。 老是这样的: www.example-name.com/category-name-exactly-same-keywords / www.example-name.com/category-name- 完全相同的关键字 /子类别名称– 完全相同的关键字 / 新url: www.example-name.com/category-name/ www.example-name.com/category/subcategory-name/ 我从类别url中删除了“ 完全相同的关键字 ”。 在我的.htaccess中我有这样的: # Category 301 redirection RewriteRule ^ -some-category-suffix(。*)$ $ 1 [L,R = 301] 这很好,如果只有一个类别级别,它会重写: www.example-name.com/category-name-exactly-same-keywords / 至: www.example-name.com/category-name/ 但是,如果有多个类别级别,它只会删除最后一个 www.example-name.com/category-name- 完全相同的关键字 /子类别名称– 完全相同的关键字 / 至: www.example-name.com/category-exactly-same-keywords / subcategory-name / ————————————————– —————————————- 如果重新(删除)“ – 完全相同的关键字 ”的所有实例,如果旧url中有多个url到没有url的新url?
我需要一个.htaccessexpression式来使用第二个getvariables或通过名称获取getvariables。 目前我的mod_rewrite改变URL去除index.php文件名,并改变pageName GETvariables,使它看起来像一个文件名。 我现在需要第二个GETvariables,但目前的方式,它甚至不承认第一次重写后获得variables,所以我想mod_rewrite处理第二个variables将是'blogpage = 1'(1将是你正在使用的博客页面),以便它看起来像这样: *********.co.uk/PageName/2 而不是这个 *********.co.uk/PageName?blogpage=2 由于目前没有这个工作,PHP脚本只是认为var不存在,并返回一个NULL值。 这是我目前的mod_rewrite条件: RewriteCond %{REQUEST_fileNAME} !-d RewriteCond %{REQUEST_fileNAME} !-f RewriteRule ^([^/\.]+)/?$ index.php?pageName=$1
我目前有2个服务器容器,http为1,另一个为同一个服务器,但https。 我想用Listen 80;合并这些容器Listen 80; 和Listen 443 ssl; ,这工作,但我需要重写一个不同的URL: location ^~ /wp-admin { rewrite ^ https://domain.com$request_uri? permanent; } location ^~ /wp-login.php { rewrite ^ https://domain.com$request_uri? permanent; } 当HTTP和HTTPS结合使用时,会导致无限的位置循环。 我需要改变模式,但我没有得到它的工作: location ~ ^http://domain\.com/wp-admin { rewrite ^ https://domain.com$request_uri? permanent; } location ~ ^http://domain\.com/wp-login.php { rewrite ^ https://domain.com$request_uri? permanent; } 这不行,有人知道吗?
我已经build立了一个vHost,如下所示: <VirtualHost *:80> ServerAdmin [email protected] ServerName example.com ServerAlias www.example.com DirectoryIndex index.php DocumentRoot /var/www/example.com/www/ <Directory /> Options -FollowSymLinks -Includes -Indexes -MultiViews AllowOverride None </Directory> <Directory /var/www/example.com/www/> <LimitExcept GET POST> deny from all </LimitExcept> Options -FollowSymLinks -Includes -Indexes -MultiViews AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost> 我想添加一个重写规则如下: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] RewriteCond %{HTTP_HOST} […]
我有一个来自旧Joomla安装的RSS feed example.com/?format=feed&type=rss 。 该站点现在使用Jekyll构build,并使用新的URL example.com/rss.xml作为RSS提要。 重写规则不适用于我,因为URL以“?”开头。 我有它的工作与if指令,但要避免使用if 。 这里是我想用重写或redirectreplace的工作if指令: if ($args ~ "type=rss") { rewrite ^ https://example.com/rss.xml? permanent; } 可以以“?”开头的URL指令 被重写还是redirect?
我正在用Nginx写一些干净的URL实现的PHP CMS代码。 为了提高我的代码的安全性,我想重写我的根目录中的所有请求/使用以下types: rewrite ^(.*)$ /index.php?q=$1 last; 有了这种重写,其余的PHP脚本将无法从用户的一面访问(他们将只有,如果包括在PHP中,我是吗?)。 但是,我不想在一个位置重写请求(因为我/static/ ),因为我将只提供静态内容,如图像和CSS从该位置。 我怎样才能使这个重写不能在某些地方工作?
我在这个目录树中build立了一个PHP项目: 项目 V1 应用程序(项目文件) 上市 index.php(控制器的应用程序) 文件 PHP文件 例子 PHP文件 “项目”是networking服务器的根源。 我想跳过url的“公开”部分,但保留“v1”: http://myserver.com/v1/whatever/1 并不是 http://myserver.com/v1/public/whatever/1 我得到了这个工作: rewrite ^(.*)$ /v1/public/index.php?_url=/$1; 另外我希望能够通过这个URL结构来处理“documentation”和“examples”中的文件 : http://myserver.com/v1/documentation/file_name.php http://myserver.com/v1/examples/file_name.php 我使用这两个.htaccess文件在Apache中工作: #/项目/ V1 /的.htaccess 重写引擎 RewriteRule ^ $ public / [L] RewriteRule(。*)public / $ 1 [L] #/项目/ V1 /公/的.htaccess RewriteEngine On RewriteCond%{REQUEST_FILENAME}!-d RewriteCond%{REQUEST_FILENAME}!-f RewriteRule ^(。*)$ index.php?_url = / $ 1 [QSA,L] 我尝试将这些设置转换为Nginx失败。 […]
您好我已经find了许多mod-rewrite和Apache的资源,但我还没有成功的做一个工作的例子。 下面的例子适用于 ✓WORKS example.com/en/page1.php☞example.com/page1.php?ln=en (内部redirect) ✓WORKS example.com/page1.php☞example.com/en/page1.php (redirect) ✓WORKS example.com/en/☞example.com/index.php?ln=en (内部redirect) ✓WORKS example.com/☞example.com/en/ (redirect) ✓WORKS example.com/blahblah☞example.com/en/error.php (redirect) ✓WORKS example.com/zh/blahblah☞example.com/zh/error.php (redirect) ✖FAILS example.com/de☞example.com/en/error.php (redirect – 应该是example.com/de/ ) ✖失败example.com/de/blahblah☞example.com/en/error.php (redirect – 应该是example.com/de/error.php ) <IfModule mod_rewrite.c> RewriteEngine On DirectorySlash On # Force hostname without www REDIRECT RewriteCond %{HTTP_HOST} !^example\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^(.*)$ http://%1/$1 [R=301] # […]
我有一个子目录下面的.htaccess : RewriteEngine on RewriteRule ^file.js$ file.php 包含上述和其他文件的目录如下所示: dir/ ├── index.html └── js ├── file.php └── .htaccess 我想我的file.js被内部redirect到file.php 。 当我在/var/www/html/ dir下finddir ,我的vhost定义如下所示: DocumentRoot /var/www/html <Directory "/var/www/html"> AllowOverride All Require all granted </Directory> #Alias /dir "/tmp/dir" #<Directory "/tmp"> # AllowOverride All # Require all granted #</Directory> 它的作品 ! 但是,当我将dir移动到/tmp/并将vhost更改为如下所示: DocumentRoot /var/www/html #<Directory "/var/www/html"> # AllowOverride All […]