w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Nginx 'rewrite or internal redirection cycle while internally redirecting' resulting in 500
Have you tried something like this? (specific to Magento maybe) server { listen 80 default; ssl off; root /var/www/magento; server_name mydomain.com.au; location / { index index.html index.php; try_files $uri $uri/ @handler; expires 30d; } location ^~ /app/ { deny all; } location ^~ /includes/ { deny all; } location ^~ /lib/ { deny all; } location ^~ /media/downloadable/ { deny all; } location ^~ /pkginfo/ { deny all; } location ^~ /report/config.xml { deny all; } location ^~ /var/ { deny all; } location /var/export/ { ## Allow admins only to view export folder auth_basic "Restricted"; ## Message shown in login window a

Categories : Wordpress

Stripes: How to filter request parameters from Clean URLs when applying Security Redirection
At which life cycle stage you are trying to security manager class intercept a request. Try to intercept at life cycle stage "RequestInit" where the request is about to be handled or using @Intercepts(LifecycleStage.RequestInit). Or You can also try to put before life cycle stage "ActionBeanResolution" where action bean that is targeted by the request is determined from the URL.

Categories : Misc

How do I make nginx proxy some urls on a domain to one location and the rest to somewhere else
You can refer to "rewrite" and "proxy_pass" directive in nginx manual and this can be solved easily: location ~* "^/$|^/(a|b|c).*?$" { rewrite "^/(.*)$" /site/$1 break; proxy_pass http://127.0.0.1:8001; ......; // to add any commands you need break; } location / { proxy_pass http://127.0.0.1:8002; ......; // to add any commands you need break; } Because no rewrite directive wrote in server block, Nginx start to match url in location phase. If is is caught by one location (here using the 1st one as example), then enter into rewrite loop. "break" in the end of rewrite means jump out the rewrite loop. Then start dealing with other directives in this location ,here proxy_pass will be dealt with. General process in this case would be: location match --> rew

Categories : Nginx

htaccess 301 redirection of urls w/ parameters to url w/o parameters
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} ^id= [NC] RewriteRule ^ %{REQUEST_URI}? [R=301,L]

Categories : Apache

Where is my nginx being configured? Changing nginx.conf still brings me to the 'Welcome to nginx' page
when you rewrited the nginx.conf in the folder of source code of nginx and installed it firstly, it will be copied to /usr/local/nginx/conf/nginx.conf (without specially modification of the configure in the folder of source code). But when you do this secondly, the nginx.conf in the folder of source code will be copied to /usr/local/nginx/conf/nginx.conf.defualt,and it usually don't work unless you use nginx -c /usr/local/nginx/conf/nginx.conf.defualt to assign its configure file evertime. There is a line NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" in your script above,which indicates the configure file clearly. To handle this, I suggest rewrite /usr/local/nginx/conf/nginx.conf (not the one in the folder of source code) instead.

Categories : Nginx

Restarting nginx: nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable
Passenger takes what you set in the file nginx.conf by passenger_ruby, for example: passenger_root /home/dev/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.5; passenger_ruby /home/dev/.rvm/wrappers/ruby-1.9.3-p448/ruby;

Categories : Ruby

Can a server run Nginx for some sites and Apache Nginx Reverse Proxy for others?
server { server_name example.com; location / { # assuming apache is on port 81 for example proxy_pass http://127.0.0.1:81; # to make apache detect the host header proxy_set_header Host $host; } # if you have assets folders, you can let nginx serve them directly, # instead of passing them to apache location /images { # or /css or /js .. etc try_files $uri =404; } } Note: in the case of assets, sometimes some sites serve assets through rewrites, or even handled by the application it self, you can pass it to apache by adding that in the assets location as a fallback like this location /images { try_files $uri @apache; } location @apache { proxy_pass http://127.0.0.1:81; } In apache you create a virtual host <Virtua

Categories : Apache

Python HTML parsing script that takes array of URLs and outputs specific data about each of the URLs
import urllib2 from bs4 import BeautifulSoup url = 'http://www.youtube.com/watch?v=QOdW1OuZ1U0' f = urllib2.urlopen(url) data = f.read() soup = BeautifulSoup(data) span = soup.find('span', attrs={'class':'watch-view-count'}) print '{}:{}'.format(url, span.text) If you do not want to use BeautifulSoup, you can use re: import urllib2 import re url = 'http://www.youtube.com/watch?v=QOdW1OuZ1U0' f = urllib2.urlopen(url) data = f.read() pattern = re.compile('<span class="watch-view-count.*?([d,]+).*?</span>', re.DOTALL) r = pattern.search(data) print '{}:{}'.format(url, r.group(1)) As for the outputs, I think you can store them in a csv file.

Categories : Python

Flask approach to creating URLs for resources whose URLs are different in production and in dev
The endpoint name needs to include the argument you want to pass to url_for. @bp.endpoint("/image_repo/<path:path>") def image_repo(path): if in_development(): return send_from_directory(current_app.instance_path, "<relative path>") else: return redirect("<cdn path>") EDIT: after re-reading the question, my original answer below isn't really a direct answer since you want to use a CDN, not just a separate location, sorry. Flask has a builtin solution for this called the instance folder. By default the instance folder will be next to your package (or module) during development, or in /<install prefix>/var/<package name> when installed in site-packages in production. You can access it's contents without knowing it's path with curren

Categories : Python

How can i read a file for urls and then launch all the urls in browser using python
with open('Path/to/file', 'r') as content_file: content = content_file.read() urls = content.split() for url in urls: webbrowser.open(url) You can also try webbrowser.open(url, 2) to try to open the links in new tabs.

Categories : Python

How to rewrite old urls to new urls to preserve Google Ranking
Note that Redirect is not part of mod_rewrite, it's part of mod_alias, and you don't need to turn on the rewrite engine to use it. If you wanted to "rewrite", as in, change the URL internally within the server, and the rest of the internet doesn't know it's been changed, then you'd use mod rewrite, and not a redirect: RewriteEngine On RewriteRule ^/?sompage/index.html$ /page.php?id=10 [L] If you want to redirect all requests to the new URL(s), then you can use Redirect just by itself. This lets the rest of the internet know that the URL has been changed and to stop going to the old one. With a 301, google knows that whatever metadata it has stored for the old URL should get migrated to the new URL when there is a 301 redirect (permanent): Redirect 301 /somepage/index.html /page.php?id

Categories : Htaccess

Redirect wordpress urls to joomla urls on the same domain
Use RedirectMatch to specify a pattern. RedirectMatch 301 /([^/]+)/([^/]+) /$1/category/id-$2.html Using mod_rewrite instead, you would be able to restrict the redirection to happen only when the URL path (i.e. the directory structure /eng/news/) physically does not exist. RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d # not a dir RewriteCond %{REQUEST_FILENAME} !-f # not a file RewriteRule ^([^/]+)/([^/]+)$ $1/category/id-$2.html [R=301,L] This assumes your .htaccess resides in the web root folder.

Categories : Wordpress

how to redirect users from old urls to new urls in SEO friendly manner
You should go with php just add following code in your old URL, it will redirect you to new URL new URL1 <?php header("Location: http://threads.example.com/IN/24/215/sample-thread.html"); ?> Do this for all pages

Categories : PHP

htaccess redirect urls to specific urls
Your regex should match the number, but not include it in the ()'s. ex: RewriteRule ^newsroom/press-release/item/[0-9]*-(.*)$ /press/$1 [R=301,NC,L] The [0-9]* matches an arbitrary length number, followed by the -. Only what's matched parens will be included in $1.

Categories : Htaccess

django - urls.py how to differ almost same urls from each other
Instead of .+ (which takes all characters up to the end), use w+: url(r'^bundesland/(?P<bundesland>w+)/$','home.views.func_a'), This will take one or more letters between the slashes.

Categories : Python

Does $PATH need subdirectories
The entries are independent of each other, and only count the direct contents. Try it. > mkdir ~/bin > mkdir ~/bin/test > cp /bin/echo ~/bin/test/echotest > export PATH=$PATH:~/bin > echotest Hello, world -bash: echotest: command not found > rm -rf ~/bin/test

Categories : Osx

WIX ComponentGroup subdirectories
here is my full example I hope this help further developers </Product> <Fragment> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFiles64Folder"> <Directory Id="GiladDir" Name="Gilad"> <Directory Id="INSTALLFOLDER" Name="App"> <Directory Id="BIN" Name="bin"></Directory> </Directory> </Directory> </Directory> <Directory Id="ProgramMenuFolder" Name="Programs"> <Directory Id="ProgramMenuDir" Name="App"> <Component Id="ProgramMenuDir" Guid="*"> <RemoveFolder Id="ProgramMenuDir" On="uninstall" /> <RegistryValue Root="HKCU" Key="Software[Manufacturer][ProductName]" Type="s

Categories : C#

PHP: Navigating through subdirectories
You may start link with / (slash). It means address in current site from root of the site. See example for clarity <a href="/link_from_root_of_the_site">Link</a> Example: Badges (<a href="/help/badges/">Badges</a>)

Categories : PHP

Max # subdirectories on Linux box
It depends on your filesystem. The following thread has more information on the limits of various filesystems: What is the maximum number of folders allowed in a folder in Linux?

Categories : Linux

JSF 2.2 resources in subdirectories of library
Sorry for the inconvenience. As it turned out, my glassfish had some bad cache. Neither hot redeploying, nor restarting helped. After clearing the whole ear and all it references in the domain and deploying a fresh copy, everything worked fine as expected.

Categories : Java

Ant Zip Task, many excludefiles in subdirectories
Sounds like a good use case for custom selectors: http://ant.apache.org/manual/Types/selectors.html#customselect You'll probably need to write your own selector as explained here: http://ant.apache.org/manual/Types/selectors-program.html

Categories : Ant

Unzipping subdirectories and files in C#
if your archive looks like this: archive.zip file.txt someFolder file2.txt then entry.FullName for file2.txt is someFolder/file2.txt so even your code will work normaly if the folder exists. So you can create it. foreach (ZipArchiveEntry entry in archive.Entries) { string fullPath = Path.Combine(extractPath, entry.FullName); if (String.IsNullOrEmpty(entry.Name)) { Directory.CreateDirectory(fullPath); } else { if (!entry.Name.Equals("please dont extract me.txt")) { entry.ExtractToFile(fullPath); } } } or you should better use static ZipFile method if you need to extract all the archive ZipFile.ExtractToDirectory(zipPath, extractPath);

Categories : C#

execute command in subdirectories
The loop is correct, you will iterate over all txt files in subdirs of the current pwd (where this script or command is being executed). You don't have to change directory to save the output in that subdir. Linux don't take care of it :) You can delete everything after first / using variable expansion ${x%%/*} Try for x in */*.txt; do command "$x" > "${x%%/*}"/output.fsa done Remember, if you have more txt files in that subdir, you will execute command "$x" more times and rewrite the output.fsa. You can use append (>>) in that case Try for x in */*.txt; do echo "Executing command "$x"" >> "${x%%/*}"/output.fsa command "$x" >> "${x%%/*}"/output.fsa done

Categories : Unix

How to remove two subdirectories from a URL via mod_rewrite?
It's probably got something to do with the way wordpress is extracting the path info and request URI information. If you request /page and even if the rewritten request gets to wordpress, wordpress may be looking at the request URI and see "/page" and assume that's a 404. I'm sure there's some wordpress specific way of handling these sort of things, but if you have mod_proxy loaded, you can try adding a P flag in your rule: RewriteRule ^page$ /subdirectoryone/subdirectorytwo/page [NC,QSA,L,P] So that the request /subdirectoryone/subdirectorytwo/page goes through the entire request handling process in it's own request.

Categories : Wordpress

Remove two subdirectories from url with mod_rewrite
You need to get rid of the leading / in your regex pattern. The slash is stripped off when URI is sent through rules in an htaccess file. Also, you should instead check to see if the destination exists before rewriting into the /public/user/ directory: RewriteCond %{REQUEST_URI} !^/public/user RewriteCond %{DOCUMENT_ROOT}/public/user%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}/public/user%{REQUEST_URI} -d RewriteRule ^(.*)$ /public/user/$1 [L] Also, do I have to modify the html href like this <a href="/settings.php">? Yes, the rule only works in one direction, regex pattern to target. Never the other way around. So you need to make sure your content has the URLs that you want to use.

Categories : Apache

Renaming all subdirectories using Ruby
The problem is that Dir.glob("**/*") returns an array like this: ['folder', 'folder/sub', 'folder/sub/sub'] Now when you do: File.rename(file, File.dirname(file) + File::SEPARATOR + "2") it will rename folder, but when it reaches folder/sub, that doesn't exist anymore, because you have renamed folder to 2: it will be 2/sub instead of folder/sub. The solution is to reverse the array. This starts the renaming process on the deepest level and works its way up to the top level: Dir.glob("**/*").reverse.each do |file| # rest of your code can stay the same end As for your second problem, instead of: FileUtils.remove_dir ("2", force = true) You should use: FileUtils.remove_dir("2", true) First of all, make sure there is no space between remove_dir and (. That's what's causing the

Categories : Ruby

having trouble walking into subdirectories
From the output it looks like it->path() is giving you the relative path, not the absolute path. While iterating, your current directory does not change, so trying to iterate over a directory with path 'b' or 'c' won't work and no subdirectories will be found in that non-existent directory. In your for-loop, try the following recursive call: walk(root/it->path()); Now, when your program examines directory c, it should output: ENTERING d:/a/c ENTERING d:/a/c/d etc...

Categories : C++

Copy the newest file from all the subdirectories
I'm not sure if you're using xcopy correctly. /O doesn't take arguments. It only copies ownership/ACL info. (Is that really what you want for log files?) Since you didn't describe what "doesn't work" means, my only suggestion is to hedge against file names with spaces in them. FOR /R "%SRC_DIR%" %%f in (*.trn) do xcopy "%%~f" "%DEST_DIR%" /B /O /D /Y This worked for me (I tested with .pdf's).

Categories : Windows

.htaccess URL Rewrite to affect Subdirectories
I know this only skirttails the issue but if you don't have the actual url point to a real folder then you can run everything from the .htaccess file from public_html. So if you actually stored the images in /data/2012/January/* Then had the url that is used by /Image/2012/January/IMG_NAME

Categories : PHP

Creating a makefile and compiling in subdirectories too
Dan. As others have mentioned in the comments, you really ought to use CMake or some other build system that generates makefiles (and other projects) rather than creating a makefile by hand. With the makefile that I provided in the tutorial, it's important to understand what each of the various variables represent. The program_C_SRCS and program_CXX_SRCS represent the C and C++ source files that are to be built. You can modify the wildcard such that they are picked up from the "src" directory rather than from the current directory. Likewise, the OBJS variables define the list of object files that are produced as output. You can similarly modify the way that this is constructed so that they get emitted in the "obj" subdirectory (though without further testing, I'm unsure whether the normal

Categories : C++

How to rename files in a directory and all subdirectories
Something like: find . -name '*xx*' -print | sed -e 's/^(.*)xx(.*)$/1xx2 1yy2 /g' | xargs -n2 mv Where 'xx' ist the search string for the file names. sed replaces the xx with yy and pipes that to xargs xargs takes now (-n2) two parameters (old and new name) and execute mv with both parms. That is only the start point, try it in a safe environment :-) You have first rename the files ( -type=f ) after that you rename the path ( -type=d ). If you change this order the mv will fail while the directory is renamed while changing the next file name :-) If there are spaces in the file names, you have to use print0 instead of print. But then you also have to change the sed part... I think the rest is your homework :-) Feel free to ask if something will not work at all.

Categories : Unix

Looping over files in subdirectories of a ZIP archive
I can't reproduce your problem. It works fine in my test case: using (var archive = ZipFile.OpenRead(zipIn)) { foreach (var zipArchiveEntry in archive.Entries) { Console.WriteLine(zipArchiveEntry); } } Console.ReadLine(); Result:

Categories : C#

deny access to all subdirectories using htaccess
You can set an environment variable if the request contains a /errors, doing something like this in your htaccess file: SetEnvIf Request_URI /errors iserrors=1 Order Deny,Allow Deny from all Allow from env=iserrors

Categories : Htaccess

How to traverse all the files in a directory and subdirectories as well
rename($file,$new_file) will not work as you did not specify the path rename("$dir_01/$dir_02/$file", $new_file) But also like that any file that matches will be renamed Kernel.txt in the current directory. Is that the expected behavior?

Categories : Perl

C# List all "leaf" subdirectories with EnumerateDirectories
This should work: var folderWithoutSubfolder = Directory.EnumerateDirectories(root, "*.*", SearchOption.AllDirectories) .Where(f => !Directory.EnumerateDirectories(f, "*.*", SearchOption.TopDirectoryOnly).Any());

Categories : C#

Adding subdirectories to Angular route
I noticed that your first example for contact had a / at the start, the second problem route did not. I think I ran into something where I had to have the / at the start or it would try to make everything relative, which caused some funky stuff. // | // V .when('/projects/dublin-bus', { templateUrl: 'views/projects/dublin-bus.html', controller: 'MainCtrl' })

Categories : Angularjs

Find and gzip files in subdirectories
Since we don't have to recurse, I'd approach it not with find but with globbing and a for loop. If we're in the Calc directory, echo * will give us all the directory names: ~/Docs/Calc$ echo * 2011 2012 2013 It just so happens that we can use a for loop to iterate over these and tar them up in the usual way: for year in *; do tar czf $year.tar.gz $year done If you want the resulting tarballs in the year directories, you could add an mv after the tar command. I'd be hesitant to put the tarball in the directory from outset or tar might start trying to tar its own output into itself.

Categories : Bash

How can I load templates from subdirectories in Symfony2?
You can load templates from subdirectories with this view syntax: ProjectCoreBundle:Form:Admin/fields.html.twig or ProjectCoreBundle:Form/Admin:fields.html.twig or ProjectCoreBundle::Form/Admin/fields.html.twig

Categories : Symfony2

Is it normal to have .svn directory under most if not all of the subdirectories? - svn add issue
This depends on which subversion distribution you're running, prior to version 1.7 there was a .svn directory in every directory in the working copy. Look at Apache Subversion 1.7 Release Notes You could try to upgrade to the new format using svn upgrade

Categories : Svn

Copy All Files/Subdirectories In a File to Another
Well this is the MSDN example This example demonstrates how to use I/O classes to synchronously copy the contents of a directory to another location. In this example, the user can specify whether to also copy the subdirectories. If the subdirectories are copied, the method in this example recursively copies them by calling itself on each subsequent subdirectory until there are no more to copy. You could also have a look at Asynchronous File I/O Asynchronous operations enable you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working.

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.