mod-rewrite

redirect a single URL to another - removing the query string

随声附和 提交于 2019-12-12 17:57:16
问题 I have a single url something like this where 456 is the ID of the category and has been rewritten into a seo friendly url: http://www.mydomain.com/category/nameofcategory/456.htm (This is done with this rewrite rule: RewriteRule ^category/.*/([0-9]+) home/categoryview.php?id=$1 [L,QSA] I need to keep this intact for all the other categories.) I'd like to .htaccess redirect my 456 category to a specific product's url: http://www.mydomain.com/products/nameofproduct/123.htm If add the following

.htaccess get url to uri segments

一个人想着一个人 提交于 2019-12-12 17:43:06
问题 I want to convert the url: http://example.com/calendar/?start=1281052769&end=1283731169 into the url: http://example.com/calendar/1281052769/1283731169 This is what I have tried: RewriteEngine on RewriteCond %{QUERY_STRING} start=(.*) RewriteCond %{QUERY_STRING} end=(.*) RewriteRule ^calendar$ http://example.com/calendar/%1/%2[R,L] 回答1: RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} ^start\=([^&]+)\&end\=([^&]+)$ RewriteRule ^$ /calendar/%1/%2 [R,L] 来源: https://stackoverflow.com

htaccess redirecting multiple domains, https and http, www and non-www, all to one https domain

牧云@^-^@ 提交于 2019-12-12 17:25:47
问题 I have three different domains, and I want to make sure that all domains redirect to the one domain. I want to make sure all cases are covered: if the user types http or https, if they include www or not. This create 12 different possibilities... http://www.domain1.co.uk https://www.domain1.co.uk http://domain1.co.uk https://domain1.co.uk http://www.domain2.uk https://www.domain2.uk http://domain2.uk https://domain2.uk http://www.domain3.co.uk https://www.domain3.co.uk http://domain3.co.uk

Apache RewriteRule redirection with url encoded

萝らか妹 提交于 2019-12-12 17:22:59
问题 I have this URL (urlencoded twice): http%253A%252F%252Fwww.google.cl%252F%2523test (translated: http://www.google.cl/#test) And this Rewrite Rule: RewriteRule /linkto/(.*?)/ ${unesc:$1} [R,L] If i put this url in the browser: http://localhost/linkto/http%253A%252F%252Fwww.google.cl%252F%2523test/data/ Apache redirects to http://www.google.cl/%23test instead of http://www.google.cl/#test The problem ocurrs only with # (number sign). Any ideas? 回答1: Can you try NE flag: RewriteRule ^/?linkto/(.

Read header into environment variable in Apache 2.2?

荒凉一梦 提交于 2019-12-12 16:41:34
问题 I want to process a request header using a custom rewrite map. Therefore I want to have the content of the header in an environment variable. I have not found a way to do that with mod_headers and/or mod_rewrite. Any help is appriciated. 回答1: Mod_rewrite example for the request header "X-Forwarded-For": RewriteRule .* - [E=X-Forwarded-For:%{HTTP:X-Forwarded-For}] 来源: https://stackoverflow.com/questions/7224561/read-header-into-environment-variable-in-apache-2-2

Apache RewriteRule to remove port on any domain name

本秂侑毒 提交于 2019-12-12 16:25:08
问题 I have a virtual server with one IP address, serving a few different sites. One of them has an SSL certificate on it. I needed to add an SSL cert on a second domain for private use by myself, and as I only have one IP address, I added it on port 8080 instead. This works fine. My problem now is that all the domains that point to the server will display my private site if port 8080 is requested on that domain. https://example1.com:8080/ -> will show my private site, but shouldn't https:/

Allowing relative paths only

和自甴很熟 提交于 2019-12-12 16:23:23
问题 I believe this is an Apache .htaccess issue, and yet, maybe not. Maybe I am looking at the problem from the wrong angle, and thus can't find the proper solution. I am building a web app + hybrid mobile app. I would like to share the exact same code base, without having to tweak anything manually to deploy my app to Android or iOS, otherwise, the process of deploying will be hacky and painful. What I want is to take the web app repository, shove it into Cordova's box (you dirty man ;) , and it

How to mod-rewrite all requests to single file without causing an infinite loop

天涯浪子 提交于 2019-12-12 16:15:46
问题 How can I take all requests to www.myurl.com/{ANYTHING} and send them all to www.myurl.com/index.php I am finding I can send everything with: RewriteRule .* index.php [R=Permanent,L] This works great, except I am redirected to www.myurl.com/home/username/public_html because of my cpanel/apache installation. So instead I changed my code to RewriteBase / RewriteRule .* index.php [R=Permanent,L] But this causes the infinite loop again. 回答1: Try: RewriteCond %{REQUEST_URI} !^/index.php

HTTP to HTTPS 301 Redirection Code is Not Working, It says Too many redirects

风流意气都作罢 提交于 2019-12-12 16:12:02
问题 I am using Bluehost for one of my websites. Recently, Recently, i have moved my site from HTTP to HTTPS . After that, I have used So may different code including the below code to force HTTPS all over my website. # SSL Rewrite RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L] After using this post, when I check redirection on redirect-checker available on online, I get following messages. But it is not working. Too many redirects. Please

Nginx rewrite rule for cms backend

*爱你&永不变心* 提交于 2019-12-12 15:30:31
问题 I need to make url rewrite rules (server blocks) in nginx server same like in my previous apache server. This is code from .htaccess what I need to implement (convert) into my existing one: RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-/_]+)$ admin/index.php?hotelname=$1&do=$2 [QSA] RewriteRule ^(([A-Za-z0-9-/]+)+)$ admin/index.php?hotelname=$1 [L] This code is in my website because I need to hide in adress bar folder(/admin/) where is located files after login. And when somebody is already login,