我有一个完整的网站,如: http://www.example.com (uses index.php) http://www.example.com/scriptA.php http://www.example.com/scriptB.php 我现在想要build立子网站的可能性如下: http://alpha.example.com http://alpha.example.com/scriptA.php http://alpha.example.com/scriptB.php 从https://stackoverflow.com/questions/2844004/subdomain-url-rewriting-and-web-apps/2844033#2844033 ,我明白,我必须这样做: RewriteCond %{HTTP_HOST} ^([^./]+)\.example\.com$ RewriteCond %1 !=www RewriteRule ^ index.php?domain=%1 但是其他脚本如scriptA和scriptB呢? 我如何告诉httpd.conf正确处理这些? 我怎么能告诉httpd.conf处理“forwardslash”之后的所有内容 ,就像在主站点上一样,但是传递一个参数标志 &domain=alpha EDIT1 … I have lots of these subdomains being used, but I placed them _before_ the main 'www' one. … <VirtualHost IPADDRESS:80> ServerAlias test4.example.com ServerAdmin [email protected] DocumentRoot /home/test4/public_html ServerName […]
我试图在我的.htaccess中将引用者与主机名匹配,并偶然发现以下内容。 条件如下: RewriteCond %{HTTP_REFERER} ^https://%{HTTP_HOST}.*$ 但是,这永远不会匹配,并且mod_rewrite的日志文件指出: RewriteCond: input='https://mysite.com/test.htm' pattern='^https://%{HTTP_HOST}.*$' => not-matched 为什么HTTP_HOSTvariables在这种情况下不能被扩展?
有人可以帮我用mod_rewrite规则来处理这种情况吗? 我只需要从论坛部分删除's'。 从 www.test.com/test-forums/anystring/anystring 要么 test.com/test-forums/anystring/anystring 至 /test-forum/anystring/anystring 可以这么说,只有S在“论坛”结束时被删除。 任何帮助将是伟大的。 干杯
目前我使用以下服务托pipe我自己的(Ubuntu)服务器:samba,ftp和web服务器。 我已经买了一个域,并将DNS A-record连接到我的ISP的IP。 这工作正常。 现在我想使用DNS通配符logging来创build子域。 我想避免在DNS更改完成之前等待24小时。 因此,我只能将所有传入的通配符redirect到相同的目录: test1.domain.comredirect到/ var / www test2.domain.comredirect到/ var / www 虽然我想得到: test1.domain.comredirect到/ var / www / test1 test2.domain.comredirect到/ var / www / test2 我的猜测是要更改文件/ etc / apache2 / sites-available / domain。 任何帮助或提示将受到欢迎! 谢谢, 标记 编辑: 这是我的/ etc / apache2 / sites-available / domain文件的样子: <VirtualHost *:80> ServerAdmin webmaster@domain DocumentRoot /var/www/webroot <Directory […]
我试图定义一个mod重写规则应该这样工作:contact.php – > index.php?page = contact 我的htaccess文件有以下内容: RewriteEngine On RewriteBase / RewriteRule ^%1$ index.php?page=%1 [L] 不幸的是,这给了我一个404.任何想法有什么不对? 谢谢
我是Apache的mod_rewrite新手,我有一些困难得到它做我想要的。 在我的静态目录中,我有一些JavaScript文件( .js )与2种文件名: xxxx.js这是标准的文件名 AT_xxxx.js (带有前缀的文件名),与以前的标准文件名重复,但也包含我的自定义 我想parsing每个标准请求的JavaScript文件( xxxx.js )的请求,以检查包含所有子目录的自定义文件是否存在( AT_xxxx.js )。 然后,在这种情况下,使用自定义文件而不是标准文件(也许通过内部redirect)。 我试图弄清楚这个好几个小时,但还是有一些错误。 注意:另外,我不知道如何在子目录中find自定义文件。 DocumentRoot "/data/apps/dev0/custom/my_static" <filesMatch "\\.(js)$"> Options +FollowSymLinks RewriteEngine on RewriteCond %{DOCUMENT_ROOT}/AT_$1.js -f RewriteRule ^(.*[^/])/?$ %{DOCUMENT_ROOT}/AT_$1.js [QSA,L] </filesMatch>
只是想知道如何在我的URL的末尾使用Mod_Rewrite添加尾部的斜线? 这是我的.htaccess文件目前: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]*)$ index.php?pageName=$1 我的url显示如下: WWWW。****。com /网页 我希望它显示如下: WWWW。****。com /网页/ 该URL在内部持有GET请求,但我希望它看起来像一个真正的目录。
我试图build立一个新的服务器与几个虚拟主机,但也如此,如果请求的fqdn不匹配虚拟主机,然后请求被redirect到http://example.com/log.php?url=fqdn 我已经得到了默认的主机redirect,但我定义的虚拟主机不起作用。 我正在使用不同的主机进行testing,并在命令行上使用curl -I http://hostname.example.com:8080/来读取html头文件,以直接检查redirect头,而不是使用浏览器跟踪(避免任何caching问题)。 我已经定义了一个虚拟主机作为服务器的fqdn,但是当我使用curl来请求该虚拟主机时,我得到了redirect。 如果我通过没有定义虚拟主机的其他名称来请求服务器,我也会被redirect。 ubuntu上的apache版本是2.2.16 configuration(从几个不同的文件按顺序连接在一起)如下所示: Listen 8080 NameVirtualHost * <VirtualHost _default_> ServerAdmin [email protected] RewriteEngine On RewriteRule ^(.*)$ http://example.com/log.php?url=%{HTTP_HOST}$1 [R=302,L] </VirtualHost> <VirtualHost *> <Directory "/var/www"> allow from all Options Indexes </Directory> DocumentRoot /var/www ServerName hostname.example.com </VirtualHost> 我也尝试了hostname.example.com:*和hostname.example.com:8080的ServerName值 如果我不够清楚: anything.anything.anything.any / something requests from my server should redirect to example.com/log.php?url=anything.anything.any/something 从我的服务器请求的foo.example.com(未定义为VirtualHost)应该redirect到example.com/log.php?url=foo.example.com hostname.example.com(定义为VirtualHost)从我的服务器请求应该返回一个HTML文档 从我的服务器请求的anothername.example.com(也定义为VirtualHost)应该返回一个html文档 […]
我正在尝试使用image processing应用程序。 它需要一个.htaccess文件中的Apache指令。 但是不pipe我对RewriteRule做什么,我都无法得到它的工作。 导致服务器500错误。 规则是: RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php 这应该采取任何JPG / GIF / PNG文件,并将其发送到adaptive-images.php文件,它将通过一个图像大小的过程中运行。 在这一点上,我超越了我对RewriteRules的专业知识。
我有一个网站与域名mysite.com。 我想这样做,如果用户input“mysite.com”将redirect到“www.mysite.com”。 另外,“mysite.com/subdir”也将redirect到“www.mysite.com/subdir”。 我已经查看了vhost的更改并重写了,但是它不适用于“mysite.com/subdir->”www.mysite.com/subdir“的情况。 每次input“mysite.com/subdir”,都会redirect到“www.mysite.com”。 只有“www.mysite.com/subdir”才有效。 不知道如何解决这个问题。 我打开重写日志,但没有看到任何明显的。 这是我的configuration文件到目前为止。 请让我知道我错过了什么。 谢谢! 仅供参考:我在Apache 2.2.3上使用了CentOS 5.4,nginx 1.2.0。 该网站本身是用CodeIgniter框架构build的。 http.conf的: ServerTokens Prod ServerRoot "/etc/httpd" PidFile run/httpd.pid Timeout 120 KeepAlive Off MaxKeepAliveRequests 100 KeepAliveTimeout 15 <IfModule prefork.c> StartServers 8 MinSpareServers 5 MaxSpareServers 10 ServerLimit 256 MaxClients 60 MaxRequestsPerChild 10000 #StartServers 8 #MinSpareServers 5 #MaxSpareServers 20 #ServerLimit 256 #MaxClients 256 […]