所以我有我的htaccess文件设置,它看起来像这样: Options +FollowSymLinks RewriteEngine on RewriteBase / # MAGIC RewriteCond $1 !/$ RewriteCond $1 !\. RewriteRule ^(.+)$ /$1/ [R=301,L] # //MAGIC RewriteCond %{HTTP_HOST} !^www\. RewriteCond %{HTTP_HOST} ^([a-z0-9][-a-z0-9]+)\.domain\.com RewriteCond %{REQUEST_URI} !^/subdomains/ RewriteRule ^(.*)$ /subdomains/%1/$1 [P,NC,QSA] 我工作得很好,很好地指导phpmyadmin.domain.com到phpmyadmin.domain.com/subdomains/phpmyadmin/ 但我认为这是相当丑陋的,这表明在url。 所以我希望它静静地redirect,所以它仍然指向phpmyadmin.domain.com/subdomains/phpmyadmin/,但客户端只能看到phpmyadmin.domain.com 我一直在环顾四周,但我找不到像我想要的那样工作的任何东西。 有没有人有一个想法如何解决这个问题?
我只是将我的服务器从apache2切换到nginx,现在我的.htaccess重写有一些问题。 <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes… RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller… RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] 我已经收集到,为了使这个工作在Nginx上,我将需要编辑Nginx服务器块。 任何人都可以告诉我如何? 非常感谢你提前。
我试图学习重写,通过做这样的事情: ^/blog/install/(.*)$ –> /blog/install/index.php?_p=$1 然而,这些重写只是保持失败,很难调查,所以我看了,发现rewrite_log on作为一个适当的function来帮助我。 我的服务器块中的error_log被设置为notice级别按照NGINX指南,但是无论我放置rewrite_log on和重新加载它将永远不会logging任何有关重写,只有nginx / php错误! 我试图甚至设置error_log debug它会给我的唯一相关的信息是以下行: 2015/12/14 13:46:26 [debug] 17458#0: *4494 http copy filter: 0 "/blog/install/index.php?_p=" 2015/12/14 13:46:26 [debug] 17458#0: *4494 http finalize request: 0, "/blog/install/index.php?_p=" a:1, c:1 然而,围绕它的任何东西(包括谈论SSL和HTTP过滤的行)都提及了_p=或者全部。 一些testing,我已经用于重写,我已经尝试了许多组合: location /blog/install { try_files $uri $uri/ @install; } location @install { fastcgi_pass unix:/var/run/php5-fpm-site_mainsite.sock; fastcgi_param SCRIPT_FILENAME $document_root/blog/install/index.php; fastcgi_param QUERY_STRING _p=$uri&$args; […]
我越来越mod_rewrite和双斜杠问题 你能帮我吗? # ProxyPass /balancer-manager ! RewriteRule /phoenix/^(.*) http://phoenixstagingappa.scan-shipping.com:8080/phoenix/$1 [P] ProxyPass /phoenix/ balancer://phoenix/ ProxyPassReverse /phoenix/ http://phoenixstagingappa.scan-shipping.com:8080/phoenix RedirectMatch 301 ^(.*) /phoenix/ RedirectMatch 303 ^/phoenix$ /phoenix/
下面重写工作正常: rewrite ^/city/restaurants$ /city/listings/restaurants permanent; 但这不起作用 rewrite ^/city/restaurants$ /city/listings/restaurants last; rewrite ^/city/restaurants$ /city/listings/restaurants break; 我究竟做错了什么? 低于整个nginx服务器块 server { listen 80 default backlog=1024; server_name mydomain.com; client_max_body_size 20M; charset utf-8; keepalive_timeout 50; access_log /var/log/access_log main; error_log /var/log/error_log info; root /var/www/; index index.php index.phtml index.html; autoindex on; location ~ \..*/*\.php$ { return 403; } location ~^/sites/.*/private/{ return 403; […]
它是如何设置的 我有一个网站,这是设置为干净的url与Apache mod_rewrite是这样的: RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L,QSA] 该网站还使用了一个名为Cockpit的CMS,它位于我的公共目录下,它的干净的URL包含一个类似的.htaccess文件: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L] 在这两种情况下RewriteEngine On也存在(当然)。 现在在Apache这导致我的网站的URL被重写这样的 http://domain.com/a http://domain.bom/b 和驾驶舱的url几乎一样: http://domain.com/cockpit/a http://domain.com/cockpit/b 我正在调查所以我一直在考虑离开Apache的背后lighttpd,我已经搞乱了他们的mod_rewrite语法和configuration相当多,但我遇到了一个问题,驾驶舱url不完全清洁。 这是我如何在lighttpd上设置的: $HTTP["host"] == "domain.com" { server.document-root = "/var/www/domain.com/public_html" index-file.names = ( "index.php" ) $HTTP["url"] =~ "^(\/cockpit)(\/[a-zA-Z0-9\.]*)*$" { url.rewrite-if-not-file […]
我正在运行安装了rewrite_module的Apache 2.2.15。 我有如下规则在我的vhost.conf: RewriteRule \n ^/advanced/selector/profiles/([A-Za-z0-9]+)/?$ \n "/advanced/selector/profiles/rewrite.cfm?path=$1" [L] 这应该捕获不存在的path,并将请求redirect到捕获组作为URL.path参数的rewrite.cfm文件(../profiles/文件夹中的唯一文件)。 但是,我目前正在得到一个403错误。 我的服务器访问日志正在logging403,但我的错误日志不是。 devserver.mydomain.co.uk – – – [25/Jan/2016:12:17:47 +0000] "GET /advanced/selector/profiles/FirstYearAllowance HTTP/1.1" 403 95 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36" 如果有我忽略包括的有用信息,很乐意发布更多的细节。 我会很感激,如果有人可以告诉我如何得到这个工作!
我有一种情况,我需要强制我站点中的每个页面redirect到HTTP,除了需要强制redirect到HTTPS的两个特定URL。 需要redirect到HTTPS页面的两个页面是: /微软MOC点播video培训/ MOC-注册页/ /课程/注册/ 我在我的.htaccess文件中使用的代码如下所示: RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !^/courses/register/ RewriteCond %{REQUEST_URI} !^/microsoft-moc-on-demand-video-training/moc-registration-page/ RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{HTTPS} off RewriteRule ^(/courses/register/|/microsoft-moc-on-demand-video-training/moc-registration-page/)/ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 不幸的是,这似乎并没有工作。 整个站点都会redirect到HTTP(因此部分代码可以工作),但这两个例外(应该redirect到HTTPS)不会这样做,它们仍然是HTTP链接。 任何想法我在这里做错了吗?
我有两个规则同时工作的问题,我的conf文件 <VirtualHost *:80> ServerName mytest.domain.com ServerAlias www.mytest.domain.com mytest2.domain.com www.mytest2.domain.com RewriteEngine on RewriteRule ^ https://mytest.domain.com%{REQUEST_URI} [R=301,L] </VirtualHost> <VirtualHost *:443> ServerName redirects.for.mytest.domain.com ServerAlias www.mytest.domain.com mytest2.domain.com www.mytest2.domain.com RewriteEngine On RewriteRule ^/(.*) https://mytest.domain.com/$1 [L,R] </VirtualHost> <VirtualHost *:443> ServerName mytest.domain.com DocumentRoot /var/www/mytest/ SSLEngine on SSLCertificateFile my.crt SSLCertificateChainFile my.chain SSLCertificateKeyFile my.key </VirtualHost> 我正在努力实现的是: 来自HTTP的所有内容都被redirect到HTTPS 所有别名和www域必须redirect到其“主体”版本 我可以做一个或另一个,但混合创build一个无限的redirect循环,什么是正确的方式?
目前运行在Ubuntu的Apache服务器上的网站,现在整个网站是用.htaccess身份validation保护。 要做的事:我需要允许两个URL没有身份validation。 sites1.conf <VirtualHost *:80> … RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/(tools|manager)/ </VirtualHost> <Directory /srv/site1/symfony/> AuthType Basic AuthName "My Area" AuthBasicProvider file AuthUserFile "/etc/apache2/passwords.htpwd" Require user user1 SetEnvIf Request_URI ^/en/App/uploadImagesForm allow Order allow,deny Allow from env=allow Satisfy any </Directory> URL:xxx.xxxx.xx:9005 / en / App / uploadImagesForm / 错误: 404 Not Found请求的URL / en […]