rewrite

.htaccess switch between mobile en desktop view?

随声附和 提交于 2019-12-21 23:21:48
问题 I have the following htaccess file. This will redirect users to m.website.com when a mobile device is detected. This works, however, when people visit the mobile website on m.website.com they have the option to switch to desktop view (if they prefer). When they clicked on desktop view they will be send to www.website.com (which at this point sends them back to m.website.com) but in this situation I like to keep them at the original website at www.website.com. Is there a way with the COOKIE

rewrite and url decoding

霸气de小男生 提交于 2019-12-21 20:57:44
问题 It seems a site is linking to mine in a bad way. From google webmaster tools I see some 404 errors domain.com/file.php?id=1 (404) Not found (Date) This url works ok but because of browser page decoding, the real (404) url is domain.com/file.php%3Fid%3D1 (this is what my browser displays in the url input when I click on google url) My first try was RewriteRule ^(.*)\%3F(.*)$ $1?$2 [R=301, L] to change %3F to ' ? ' but it does not work. It is confusing what is real and what is en/decoded.

Can apache rewrite rules go in httpd.conf

走远了吗. 提交于 2019-12-21 12:14:25
问题 How do I create a simple apache rewrite rule to rewrite: http://domain.com/vanity to http://domain.com/foo/ Also can rewrite rules go in httpd.conf or do they have to go in a .htaccess file? Thanks in advance. 回答1: Put this in your website's <virtualhost> . RewriteEngine On RewriteRule ^/vanity$ /foo/ [L] The [L] will silently redirect, so the user will still see /vanity in the URL. You could use [R] to force a redirect. 回答2: They go in httpd.conf . Check out the doc 回答3: For httpd.conf, wrap

IIS 7 Canonical URL redirect

霸气de小男生 提交于 2019-12-21 09:34:52
问题 I would like to make a website always have www in the address, and enforce it via IIS rewrite. For example, test.com would become www.test.com. The typical example rewrite rule is: <rule name="Canonical Host Name" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTP_HOST}" negate="true" pattern="^www\.test\.com$" /> </conditions> <action type="Redirect" url="http://www.test.com/{R:1}" redirectType="Permanent" /> </rule> However this requires me to enter the full url of

IIS 7 Canonical URL redirect

半腔热情 提交于 2019-12-21 09:34:05
问题 I would like to make a website always have www in the address, and enforce it via IIS rewrite. For example, test.com would become www.test.com. The typical example rewrite rule is: <rule name="Canonical Host Name" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTP_HOST}" negate="true" pattern="^www\.test\.com$" /> </conditions> <action type="Redirect" url="http://www.test.com/{R:1}" redirectType="Permanent" /> </rule> However this requires me to enter the full url of

nginx - rewrite domain.com:port to sub.domain.com

坚强是说给别人听的谎言 提交于 2019-12-21 06:19:10
问题 How can i rewrite a domain with a port to a subdomain? e.q.: domain.com:3000 to sub.domain.com ? thanks for your help! :) greetz 回答1: If you actually want to redirect (301 or 302) your web traffic You create a server {} section listening on port 3000 and you just redirect it to another server {} section that is listening on port 80. In each server {} section set the listen property appropriately. I guess you are trying to handle the redirection within à single server section and according to

nginx - rewrite domain.com:port to sub.domain.com

感情迁移 提交于 2019-12-21 06:19:04
问题 How can i rewrite a domain with a port to a subdomain? e.q.: domain.com:3000 to sub.domain.com ? thanks for your help! :) greetz 回答1: If you actually want to redirect (301 or 302) your web traffic You create a server {} section listening on port 3000 and you just redirect it to another server {} section that is listening on port 80. In each server {} section set the listen property appropriately. I guess you are trying to handle the redirection within à single server section and according to

CakePHP in a subdirectory using nginx (Rewrite rules?)

淺唱寂寞╮ 提交于 2019-12-21 05:32:17
问题 I managed to get this to work a while back, but on returning to the cakephp project I had started it seems that whatever changes I've made to nginx recently (or perhaps a recent update) have broken my rewrite rules. Currently I have: worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.php index.html index.htm; }

301 redirect only if URI doesn't contain specific string

回眸只為那壹抹淺笑 提交于 2019-12-21 04:55:35
问题 I have a drupal website which has been split up to two separate websites, and now I need to setup some rewrite rules in order to drive traffic to the new site. Original website looks like this: http://www.website.com (frontpage) http://www.website.com/web1/subpage1 (subpage) http://www.website.com/web1/subpage2 (subpage) http://www.website.com/subpage3 (subpage) http://www.website.com/subpage4 (subpage) All references to subpages that are not in the web1-category have been removed from the

Nginx URL masking to a different domain

我的未来我决定 提交于 2019-12-20 12:33:51
问题 There's a few similar questions on SO, but none exactly mine, and I've had no luck trying to adapt their answers so far. I want to map the URL http://sub.example.com to https://123.12.12.12/path , such that the browser still shows the URL http://sub.example.com . My Nginx config file looks like, server { listen 80; server_name sub.example.com; location / { proxy_pass https://123.12.12.12; rewrite ^/$ /path last; } } The routing works here, but the URL displayed is http://sub.example.com/path