Articles of 重写

RewriteRule在htaccess子目录中

Windows服务器,运行Apache。 在我的Apache conf中,我有一个站点的根的AllowOverride None ,然后我有一个子目录设置为AllowOverride All : <Directory /> AllowOverride None </Directory> <Directory "/safe/"> AllowOverride All </Directory> 但是,当我尝试在子目录的.htaccess文件中设置一个重写规则时,什么也没有发生,我只是得到一个404页面未find错误。 例: RewriteEngine On RewriteRule (.*) /blah?test=$1 [R=302,NC,NE,L] 通过Apache conf重写URL可以正常工作。 我不明白为什么这个规则会被忽略。 我不想在conf中重写URL,因为在这种情况下,我可能需要不断地改变redirect,并且不希望在每次更改时重新加载服务器。 我也不想通过在站点范围内启用.htaccess文件来影响服务器的性能,只是在我需要的子目录中。

Nginx重写到以前的目录

我试图将我的博客从blog.example.com移动到example.com/blog来做到这一点我宁愿不移动磁盘上的任何东西,所以我改变了我的nginxconfiguration文件如下: location /blog { if (!-e $request_filename) { rewrite ^.*$ /index.php last; } root /home/demo/public_html/blog.example.com/current/public/; index index.php index.html index.html; passenger_enabled off; index index.html index.htm index.php; try_files $uri $uri/ @blog; } 这工作很好,但是当我访问example.com/blog nginx寻找: /home/demo/public_html/blog.example.com/current/public/blog/index.php 代替 /home/demo/public_html/blog.example.com/current/public/index.php 有没有一种方法来放入一个重写规则,以便我可以让服务器自动取出/ blog /目录? 就像是 ? location /blog { rewrite \\blog\D \; }

htaccess – redirect超过1级深度不工作

刚刚搬到GoDaddy共享主机和我试图让我的.htaccess规则工作。 下面是我拥有的: ErrorDocument 404 /error.php Options FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.mydomain\.org$ RewriteRule ^(.*)$ http://mydomain.org/$1 [R=301,L] RewriteRule ^view/(\w+)$ viewitem.php?itemid=$1 [R=301,L] RewriteRule ^category/(\w+)$ viewcategory.php?tag=$1 [R=301,L] RewriteRule ^faq$ faq.php RewriteRule ^about$ about.php RewriteRule ^contact$ contact.php RewriteRule ^submit$ submit.php RewriteRule ^contactmsg$ handler-contact.php 所有网页@根域的似乎是工作,即mydomain.org/faq,mydomain.org/about正在工作。 但每当我尝试mydomain.org/category/somecategory,我得到了一个404.我怎样才能修复我的.htaccess服从这些规则是超过1级深? 谢谢, 编辑:我已经修改了以下规则: RewriteRule ^view/(.*)$ viewitem.php?itemid=$1 RewriteRule ^category/(.*)$ viewcategory.php?tag=$1 任何人都可以证实/否认,这是解决这个问题的正确方法吗?

IIS7 URL重写规则不在网站级应用

我试图模拟托pipe与IIS7的单个网站上的多个域。 我设置了一个文件夹结构,它具有一个web_root文件夹,其中包含一个简单的index.html,一个web.config和一个持有asp.net Web应用程序的文件夹(连接)。 我试图添加一个URL重写规则,将请求到主机localhost.nerdfurio.us并将其指向连接文件夹(我也添加localhost.nerdfurio.us到我的主机文件)。 web_root中的web.config如下所示 <configuration> <system.webServer> <modules runAllManagedModulesForAllRequests="true"> </modules> <rewrite> <rules> <rule name="nerdfurious" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}" pattern="^localhost.nerdfurio.us$" /> <add input="{PATH_INFO}" pattern="^/connect/" /> </conditions> <action type="Rewrite" url="connect/{R:0}" /> </rule> </rules> </rewrite> </system.webServer> </configuration> 当我在浏览器中input“localhost.nerdfurio.us”时,我得到了index.html文件的内容。 如果我在我的浏览器中键入localhost.nerdfurio.us/connect,我得到一个404错误列表“ http://localhost.nerdfurio.us:80/connect/connect/ ”作为请求的URL。 我错过了什么?

从第三方网站提供多个域名

我想知道Google网站和Shopify等网站如何让客户创build一个网站,然后将其链接到他们自己的域名? Google网站允许用户在用户提供的域名上创build自己的网站,shopify允许用户创build他们自己的电子商务网站 – 他们可以再一次提供自己的域名来访问创build的网上商店。 在这两种情况下,虽然网站实际上由第三方公司(Google,Shopify等)托pipe,但是在浏览器中通过在用户域名中键入网站, 这怎么可能。 有没有人有一个洞察到如何(可能)正在做?

如何让wordpress在IIS 7上编写web.config以获取漂亮的url

有可能用IIS 7获得漂亮的url http://learn.iis.net/page.aspx/466/enabling-pretty-permalinks-in-wordpress/ 但是wordpress也可以自动做,如果它有权限的话。 如何在IIS 7上授予此权限?

Apacheredirect

我正在尝试redirecturl: http://www.mydomain.com/productpage.php?id=34 至 http://www.mydomain.com/products 我曾尝试使用: Redirect permanent /productpage.php?id=34 http://www.mydomain.com/products Redirect permanent http://www.mydomain.com/productpage.php?id=34 http://www.mydomain.com/products 任何人都可以指出我在这里做错了吗? 干杯 EEF

需要将主页redirect到与apache不同的文档根目录

我希望将除www.example.com和example.com之外的其他内容指向不同的根目录。 所以example.com和 example.com/page将会分为两个独立的根源。 我需要这样做,所以我可以让主页在发展中的其他地方。 这里是我的虚拟主机的网站看起来像。 ServerName www.example.com ServerAlias *.example.com DocumentRoot /var/www/example

Lightttpd重写

如何在Lighttpd中将www.domain.de/news/news_944836.html重写为www.domain.de/news_944836.html? 我所有的Trys没有工作:(

为什么不应用这个重写规则(nginx)? (试图设置WordPress的多站点)

我试图用nginx设置Wordpress多站点(子文件夹结构),但是这个重写规则有问题。 下面是Apache的.htaccess,我必须翻译成nginxconfiguration。 RewriteEngine On RewriteBase /blogs/ RewriteRule ^index\.php$ – [L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ – [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteRule . index.php [L] 以下是我想到的: server { listen […]