我的apache主服务器监听备用端口(端口8080)上的HTTP请求,但我想让用户键入我的域名(example.com),而不必指定端口。 到目前为止,我已经通过我的DNS提供商完成了这一任务,他将任何请求redirect到www.example.com或example.com到http://123.456.789.001:8080 这是一个问题,因为虽然它起作用,但是用户在他们的URL栏中得到了一个丑陋的数字。 我想要做的是将123.456.789.001:8080重写为example.com 我已经尝试阅读http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html ,但我不是URL写作的专家,我已经提出了(哪些显然不工作)是: RewriteEngine on RewriteCond %{HTTP_HOST} =123.456.789.001 RewriteRule ^(.*) example.com/$1 我放在我的httpd.conf文件中。
我有以下位置块,作为CMS的复杂路由的一部分: location @mylocation { if (-d $request_filename) { rewrite ^/(.*)$ /$controller/$siteName last; break; } if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") { rewrite ^/(.*)$ /$controller/$siteName/$1 last; } } $controller就像“index.php”, $siteName是一个散列,标识在cms中的特定网站。 它工作正常,nginx重写http://www.mydomain/path?somearg=something到http://www.mydomain/index.php/HASH/path?somearg=something 。 但是当我有一个这样的URL http://www.mydomain/path/?somearg=something nginxredirect(301)到http://www.mydomain/index.php/HASH/path?somearg=something ,和索引.php和HASH都是暴露的。 我尝试了这样的事情: location @mylocation { if (-d $request_filename) { rewrite ^/(.*)$ /$controller/$siteName last; break; } if ($request_filename ~ "") { #not sure what […]
我必须将WordPressconfiguration为运行在ASP.NET 2.0 Classic模式下的主要网站下的虚拟应用程序。 一切工作正常,PHP 5.3.13 / MySQL 5.1 / IIS 7.5,WordPress的网站也工作正常,除了重写方面。 这个博客是在www.mysite.com/blog的主机,通常重写应改写为www.mysite.com/blog/categorie/this-is-a-pretty-article,而是改写为www.mysite.com/。博客类别/这是一个漂亮的文章,正如你所看到的,它剥夺了博客和类别之间的标签,这是不合适的。 web.config中的重写规则非常直接,从自动生成的WordPress的永久链接部分: <rewrite> <rules> <clear /> <rule name="wordpress" patternSyntax="Wildcard" stopProcessing="false"> <match url="*" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php" appendQueryString="true" /> </rule> </rules> </rewrite> 我已经失去了一整天,所以我强硬要求这可能是一个好主意。 有人在IIS上有wordpress的麻烦吗? 提前致谢
目前,我正在试图将各种技术混合到一个网站上的概念certificate,以便于迁移和增加灵活性。 这个想法是在IIS 7.5 ARR反向代理之后创build一个“mashup”网站。 目前,ARR反向代理将所有请求转发给我们的主站点。 请求如下: client -> ARR: Get / ARR -> Server 1: Get / Server 1 -> ARR: 200: /index.htm ARR -> client: 200: /index.htm …到现在为止还挺好。 比方说,我想添加一个新的网站(另一台服务器的根)作为我的主要网站的子网站。 一个简单的入站规则可以做到这一点: <rule name="sub1" stopProcessing="true"> <match url="^mySubsite(.*)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Rewrite" url="http://server2/{R:1}" /> </rule> 现在的要求是: client -> ARR: Get /mySubsite ARR -> Server […]
如何将特定的https页面redirect到http,例如: https://example.com/foo – > http://example.com/foo 只为页面foo,没有其他页面。 谢谢。
在我的网站上,我有一些可以通过两个url访问的页面: …/页 … /参数/页 为了优化search引擎的网站,我必须redirect所有… /网页url… /参数/网页url。 我怎样才能达到修改文件.htaccess?
我有一个看起来像这样的configuration中的nginx 映射 : map $uri $route { /route_a /path/to/a.html; /route_b /path/to/b.html; } server { listen 8080; server_name example.dev; } 我尝试在服务器块内rewrite : rewrite ^ $route break; 但尝试访问/route_a时得到了404。 我尝试在服务器块内的location和alias : location ~ ^ { alias $route; } 哪些工作,但服务我的内容作为application/octet-stream 。 什么是正确的方法来做到这一点? 我的约束是,URIpath到文件必须在地图块内定义。
我不需要直接访问图像,而需要使用RewriteRule来redirect一组要通过脚本访问的图像。 RewriteRule用于它: RewriteRule ^Images/test/([^.\/]*)\.png /image.php?file=$1.png [R=301,L] 我希望这会改变: www.example.com/ 图片 /test/123.png 成 www.example.com/image.php?file=123.png 但它不这样做。 但是,如果我将RewriteRule更改为以下内容: RewriteRule ^Images2/test/([^.\/]*)\.png /image.php?file=$1.png [R=301,L] 以下工作: www.example.com/ Images2 /test/123.png 成 www.example.com/image.php?file=123.png 不同之处在于Images存在而Images2不存在。 是否有可能使用现有的文件夹。 任何帮助如何获得顶部的例子工作? 更新 :仔细查看mod_rewrite文档后 ,我发现: …请注意,mod_rewrite会尝试通过检查path的第一部分是否存在于文件系统的根目录来尝试猜测您是否指定了文件系统path或URLpath。 看起来,如果path被解释为一个URLpath,它将起作用,如果它被解释为一个文件系统path,它就会失败。
我不得不承认我对WebServers是全新的,现在试图弄清楚如何configuration我的nginx(用于家庭用途)。 我已经使用默认的结构在我的nginx上运行了web服务rutorrent。 现在我想改变目录结构为: /usr/share/nginx/html/ (should contain the default-config) /usr/share/nginx/rtorr_dir/ (should contain the rutorrent-content) 我的目标是:在我的浏览器中,我想input192.168.0.2/rutorrent ,这应该会自动访问rtorr_dir 。 我尝试了以下内容: server { listen *:80; access_log /var/log/nginx/access.log info; error_log /var/log/nginx/error.log debug; auth_basic "ruser"; auth_basic_user_file /etc/users.htpasswd; location /rutorrent { rewrite /rutorrent/(.*) /$1 break; root /usr/share/nginx/rtorr_dir; index index.php index.html; } location /RPC1 { include /etc/nginx/scgi_params; scgi_pass backend2; } location ~ \.php$ […]
我有一个关于查看单个post的重写规则的博客。 查看由名为view.php的文件处理。 我在我的vhostconfiguration中使用了一些重写规则,如下所示: location /view { rewrite ^/view/([^/.]+)?/?(.*) /view1.php?pid=$1&$query_string; } 这使得URL如下所示: http://domain.com/view/xxxx 其中xxxx是postID。 在同一页面上,我有一个社交分享插件,其中包含一个名为share.php的文件,位于与view.php文件相同的目录中。 该插件工作正常,但是我在我的日志中收到以下错误: FastCGI sent in stderr: "Unable to open primary script: /var/www/domain.com/view/xxxx/share.php (No such file or directory)" 我猜测它与我的nginxconfiguration文件中的上述重写规则有关。 我该如何解决这个问题? 我应该在vhostconfiguration文件中为share.php文件添加特定的重写规则吗? 这是我的PHP conf: location ~ \.php$ { root /var/www/domain.com; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_ignore_client_abort on; fastcgi_param SCRIPT_FILENAME […]