rewrite

mod_rewrite “too many redirects” problem

◇◆丶佛笑我妖孽 提交于 2019-12-13 19:27:55
问题 Trying, <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_METHOD} ^TRACE RewriteRule .* - [F] RewriteCond %{HTTP_HOST} ^(.*)dev\.example\.edu$ [NC] RewriteRule ^/test(.*)$ http://dev.example.edu/test/index.php/test$1 [NC] </IfModule> on an apache 2.2 server, to get this rewrite working to hide the "index.php/test" part of the path. everything i've tried either loops the url part (index.php/test) within the address bar or gives a "too many redirects" error. i suspect that the

CDN线上rewrite规则

会有一股神秘感。 提交于 2019-12-13 19:20:59
2019-12-09云端CDN rewrite规则: ^/.{6}[0-9]{8}/([0-9]{2})_([0-9]{2})/([0-9]+)(png|jpeg|jpg|gif)(.*)$ /uploads/picture/2016/$1/$2/$3.$4$5 ^/.{6}[0-9]{8}/([0-9]{2})_([0-9]{2})/(.*)$ /uploads/picture/2016/$1/$2/$3 ^/[a-zA-Z0-9]+/([0-9][0-9])([0-9][0-9])/([0-9]+)(png|jpeg|jpg|gif)(.*)$ /uploads/picture/2016/$1/$2/$3.$4$5 ^/.{6}[0-9]+/([0-9]{2})([0-9]{2})/(.*)$ /uploads/picture/2016/$1/$2/$3 ^/.{6}[0-9]{4}/(.*)$ /uploads/picture/2016/$1 ^/.{6}[0-9]{4}[0-9]{8}/(.*)$ /uploads/picture/$1 ^/[0-9]+\.([0-9]+)\.([0-9]+)\.([0-9]+)\.(.*)$ /uploads/picture/$1/$2/$3/$4 ^/[0-9]+/([0-9][0-9])([0-9][0-9])/(.*)$

Apache rewrite to preserve query string

笑着哭i 提交于 2019-12-13 16:50:25
问题 I have a set of rules that rewrite URL depending on the affiliate. Everything works fine However, I'm having a problem preserving the complete query string in URL. Here's my rewrite rule RewriteRule ^/(.*\.html) /adb.pl?code=${affcode:$1}&extra=%{QUERY_STRING} [PT,L] The query in URL gets stripped after affcode. URL should look like this: http://mydomain.com?utm_campaign=TEST-AFF&utm_source=TEST-AFF&utm_medium=TEST-AFF&utm_term=TEST-AFF&utm_content=TEST-AFF-JON Instead I'm getting this in my

htaccess-rewrite-rule for more than one parameter

落花浮王杯 提交于 2019-12-13 16:15:08
问题 I use the following rule RewriteRule ^([\w]+)/?([\w]+)? index.php?action=$1 for rewriting www.mysite.com/123 to www.mysite.com/index.php?action=123 This needs to remain like this, but there are cases where I also need to rewrite www.mysite.com/123/abc to www.mysite.com/index.php?action=123&example=abc How can I achieve this? Thanks! 回答1: Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory: Options +FollowSymLinks

Nginx URL Rewrite with Multiple Parameters

梦想的初衷 提交于 2019-12-13 16:09:26
问题 I am trying to rewrite the following URL via Nginx: http://www.domain.com/script.php?title=LONGSTRING&desc=LONGSTRING&file=LONGSTRING&id=THREELETTERS into something like this: http://www.domain.com/script/LONGSTRING/LONGSTRING/LONGSTRING/LONGSTRING/THREELETTERS.html All I have been able to find so far is how to include a single variable. I have five variables to pass through, each terminated by a "/". 回答1: you can access a script parameter name in nginx through the $arg_name variable

progmatically rewritemap rules at runtime

风流意气都作罢 提交于 2019-12-13 12:14:40
问题 Is it possible to add static rewritemaps rules progmatically for ASP.NET 3.5 I have:- <rewriteMaps> <rewriteMap name="My Name"> <add key="/Sales" value="/Test.aspx?id=10" /> <add key="/Sales-And-Marketing" value="/Test.aspx?id=10&dog=cat" /> </rewriteMap> </rewriteMaps> but would like to add these progmatically at runtime? 回答1: Its a little late I know, but you can do it programmatically by having the url in a seperate config <rewrite> <rewriteMaps configSource="urls.config" /> <rules> <rule

regex to replace string with params

北城余情 提交于 2019-12-13 08:52:26
问题 Please help me to create regex for replace a string like: /technic/k-700/?type=repair to a string like /repair/k-700/ Instead of k-700 can be any another combination (between / ) and instead of repair can be only kit . I need pattern and replacement, please. It's so hard for me. My result not working for Wordpress : $pattern = '/technic/([0-9a-zA-Z-]+)/?type=$matches[1]'; $replacement = '/?/([0-9a-z-]+)/'; 回答1: You can try something like this: $test = preg_replace( '~/\w+/([\w-]+)/\?type=(\w+

htaccess rewriting to include file in every folder

邮差的信 提交于 2019-12-13 07:48:37
问题 Is there a way I could use htaccess' url rewriting feature to look like there's a file in let's say the /public/some/folder when it's actually in /public . For example I have index.php in root folder and I want it to be like that when I access index.php then it could also behave as its in all the folders and subfolders too When I execute index.php then it will also execute in all folders and subfolders too Update Please understand my question by the example below index.php is in root and I

IIS 7 url rewrite using database variables

大城市里の小女人 提交于 2019-12-13 07:27:58
问题 I would like to change my urls from http://www.example.com/product.asp?productid=30 to: http://www.example.com/Samsung_LED_UE40D5000 the Samsung_LED_UE40D5000 is the product name + the product model stored in the database and is associated with the productid as the primary key. how do i write a url rewrite rule to achieve that? Thanks a lot! O.B 回答1: You have to write Custom Rewrite Provider which accesses database to resolve product name + the product model to productId. Then use this

Hypens in domain name of .htaccess rewrite

女生的网名这么多〃 提交于 2019-12-13 07:14:06
问题 the following doesn't work in my .htaccess file... Does it have something to do with the hyphen in the domain name? RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?.*.domain-name.com$ [NC] RewriteCond %{REQUEST_URI} !^/Accounts/2/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /Accounts/2/$1 [L] RewriteCond %{HTTP_HOST} ^(www.)?.*.domain-name.com$ [NC] RewriteRule ^(/)?$ Accounts/2/ [L] any ideas? 来源: https://stackoverflow.com/questions/9982476