url-rewriting

Split regular expression into 2 capture groups

杀马特。学长 韩版系。学妹 提交于 2020-01-02 08:43:21
问题 Ok, my previous questions were answered ... I have one more, this one is more difficult for me... ^([A-Za-z]+\.[A-Za-z0-9_-]+\.domain\.com)$ Right now this expression produces only 1 capture group as noted with ^() ; How would I do 2 capture groups for this URL? (for IIS regular expression rewrite) 回答1: You can do this by enclosing the relevant portions like so: text = "city.state.domain.com" pattern = "^([^\.]+).([^\.]+).([^\.]+).([^\.]+)$" match = re.match(pattern, text) match.groups() #

Mod Rewrite, pass parameters from URL1 to URL2

六眼飞鱼酱① 提交于 2020-01-02 08:23:13
问题 I'm trying to rewrite the following URL test.php?par1=foo&par2=bar Into... newtest.php?hidden_par=blah&par1=foo&par2=bar I have this rule, that does not work: RewriteRule ^test.php\??(.*?)$ newtest.php?hiden_par=blah&$1 [L] Could this be done using RewriteCond or something else? (say, could this be done ?), thanks in advance. 回答1: You probably want something like the QSA ("query string append") flag, which causes the remainder of the query string to be properly appended onto the end of the

How to remove empty parameter or parameters anywhere in URL by .htaccess?

感情迁移 提交于 2020-01-02 07:43:15
问题 Empty parameters that I mean can be anywhere in URL each time different place, each time with different name, each time on different php page e.g : http://www.example.com/AnyPHPpageHere.php?parameter1=7&parameter2=&parameter3=blue&parameter4= to the form: http://www.example.com/AnyPHPpageHere.php?parameter1=7&parameter3=blue So how to do it via .htaccess? 回答1: You can use this URL to remove any one or more empty parameters from anywhere in URLs: RewriteEngine On RewriteCond %{QUERY_STRING} ^(

How do I use www.domain.org/#!/topic/item style URLs and what are they called?

天涯浪子 提交于 2020-01-02 07:25:51
问题 On many sites I see URLs like www.domain.org/#!/topic/item in my address bar. For example the new twitter changes the URL into that. I know what the hash does when you use targets in HTML: www.domain.org/page.html#topic3 moves the browser viewport to the anchor <a name="topic3"> . Also I think that this URL scheme solves the problem of having always the right URL in the address bar on a page with dynamical loaded content. But how… …do I handle those URLs on the server side? (mod_rewrite,

PHP $_GET var with urlencode and “&” bug

穿精又带淫゛_ 提交于 2020-01-02 07:18:09
问题 In my code, I create a link like this: $link = 'http://www.mydomain.com/'.urlencode($str).'/1'; I use url-rewriting and the rule in my htaccess file looks like this: rewriteRule ^(.+)/(.*)$ index.php?var1=$1&var2=$2 [NC,L] This code is working fine for almost every strings. But sometimes, the string to encode contains "&". The urlencode function encodes it corectly, but when I read the $_GET array in php, it looks like this (with $str = 'substring1&substring2'): 'var1' => 'substring1'

nginx Wordpress URL rewrite

廉价感情. 提交于 2020-01-02 07:13:19
问题 I've just installed nginx 1.0.8 and php-fpm and for the last 30 minutes I'm trying to rewrite the URL for Wordpress. Here is what the Wordpress URL should look like: http://localhost/website/blog/2011/10/sample-post/ I've looked at this tutorial: http://wiki.nginx.org/WordPress + many other on the web but every time I receive an 404 error (sometimes 403). Here is what I did in my configuration file: location /website/blog { try_files $uri $uri/ /website/blog/index.php; } location ~ \.php$ {

Using Forms Authentication/Authorization with Rewritten URLs

随声附和 提交于 2020-01-02 07:12:18
问题 I'm doing a quick sandbox test with some Rewritten URLs (example taken from Scott Guthrie's blog) and Forms Authentication / Authorization. I've a very simple setup. ~/View/(\d{1,6}) => ~/Public/View.aspx?ContentID=$1 AND ~/Buy/(\d{1,6}) => ~/Private/Purchase.aspx?ContentID=$1 I've confirmed the URL Rewriting is working by browsing to each of the following seperately http://localhost/urltest/Public/View.aspx?contentID=123456 http://localhost/urltest/View/123456 http://localhost/urltest

Can Url Rewrite only rewrite to an internal url?

家住魔仙堡 提交于 2020-01-02 05:24:06
问题 I've installed IIS 7.0 with SharePoint and Url Rewrite module. Are the following sentences or perhaps I have configured something incorrectly to see this result? Url Redirect can redirect a url to any internal (on the same site) or external urls (on a separate site). Url Rewrite can only rewrite to an internal url? Many thanks in advance. 回答1: Url Rewrite can redirect a url to any internal (on the same site) or external urls (on a separate site). 回答2: You can actually rewrite to a different

Remove part of a URL

安稳与你 提交于 2020-01-02 04:37:26
问题 How can I remove main/ in http://domain/main/about so the URL will be like this http://domain/about Thanks 回答1: Well, in the absence of any further details, you could try something like this: RewriteRule (.*)/main/(.*) $1/$2 But this is a VERY broad rule - you'd probably want to tune it more tightly than that. Try turning the RewriteLogLevel to 9 and watching the rules as they get processed so you can get a better idea of what is being matched. 回答2: If you only need one file to be rewritten :

Rewrite condition is not working

家住魔仙堡 提交于 2020-01-01 19:45:29
问题 How to rewrite the URL for my search page in opencart that is like http://IP/opencart/index.php?route=product/search&filter_name=24 But I need to display it like http://localhost/opencart/product/search/42 orelse in any formate that is an userfreindly.I have tried like RewriteEngine On RewriteBase /opencart RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L] RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %