w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
nodejs equivalent of this .htaccess
Have you tried: Serve statics Catch /view URL Catch everything else app.configure(function(){ app.use(express.static(__dirname+'/public')); // Catch static files app.use(app.routes); }); // Catch /view and do whatever you like app.all('/view', function(req, res) { }); // Catch everything else and redirect to /index.html // Of course you could send the file's content with fs.readFile to avoid // using redirects app.all('*', function(req, res) { res.redirect('/index.html'); }); OR Serve statics Check if URL is /view app.configure(function(){ app.use(express.static(__dirname+'/public')); // Catch static files app.use(function(req, res, next) { if (req.url == '/view') { next(); } else { res.redirect('/index.html'); } }); }); OR Catch stati

Categories : Node Js

Deny from all in subdirectory htaccess not overriding file rules in root htaccess
You can have your Root .htaccess like this # Deny access to everything by default Order Deny,Allow deny from all # Allow access to html files <Files *.html> allow from all </Files> # Deny access to sub directory <Files subdirectory/*> deny from all </Files> There is no need for a separate .htaccess in the sub directory. You are allowing access to all html files in your .htaccess in the Root Directory and not denying it anywhere in the sub directory in the first case. Apache parses all your rules and uses the last matching rule, unlike firewalls (which uses the first rule match hit). The global rules are read first and the the specific rules later.

Categories : Apache

Whats the python equivalent of a `while read ... do; ... done < file` for tab delimited file?
You can use the csv module. >>> import csv >>> with open(filename) as f: for row in csv.reader(f, delimiter=' '): category, code, price, description, link, picture, plans = row

Categories : Python

How prevent browser from caching XML file served by Apache? (My htaccess file is included)
I discovered the answer but I'm not sure why it's required and how to change this behavior in Apache. If I unlink (i.e. delete) the XML file first and then recreate it (instead of just writing over it), then both browsers see the fresh version! //This causes a fresh version unlink( $xmlFileLocation ); //Now creating it will result in a non-cached version being sent $f = fopen( $xmlFileLocation, "wb" ); fwrite(, $xmlFileLocation, $xml ); fclose( $xmlFileLocation ); If I do the above without unlink, then it gets changed and the modified date is updated on disk, but Apache continues to serve the old version!! Why?

Categories : Xml

How do I remove the extension for an external file in my wordpress htaccess file?
Just add one line for your redirect as shown below: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^contact$ /contact.php [L] <-- New Line RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress

Categories : PHP

File not found with .htaccess file on Apache server
I finally solved it but in a way that I am not sure I like. At least it works. If someone has a better solution I would be glad to see it. RewriteRule ^login/([0-9]+)/([0-9]+)$ http://host/webserv/login.php?par1=$1&par2=$2 The reason I don't like this solution is because I does not give a pretty url. It just redirects. I still do not understand why I get the root directory appended to the request if I instead write: RewriteRule ^login/([0-9]+)/([0-9]+)$ login.php?par1=$1&par2=$2

Categories : PHP

How to stop .htaccess redirect from .html file to a .php file?
Firstly, you don't need a .htaccess file. An .htaccess file is simply for overwriting the server's httpd.conf file at a user-controllable and restricted level without allowing the user full control of the server's config file. If you're not using it for anything you can delete it. Because you had 301 redirects in your .htaccess file before they're likely cached by your browser (even though you deleted them from the .htaccess file). To disable a rule you can add a # comment tag in front of it. Additionally you can delete the rule. Until the redirect rules are removed, the server would send the header request for the redirect. Once it's been removed (but it's in your cache) you will need to delete your browser's cache to make the redirect stop happening. You can keep the .htaccess file

Categories : Htaccess

htaccess rewriterule to send a file to another file in the same directory
If you want to have this rule for IP: 123.456.789.10 then you shouldn't have this IP with negation like: RewriteCond %{REMOTE_HOST} ! Try this code: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase /subdir/ RewriteCond %{REMOTE_HOST} ^123.456.789.10$ RewriteRule ^index.html?$ index.php [NC,R=302,L]

Categories : Apache

htaccess redirect file request of one to another file
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 %{HTTP_HOST} ^(subdomain).(site.com)$ [NC] RewriteRule ^file.txt$ http://%2/file-%1.txt [L,R=301,NC] EDIT: RewriteCond %{HTTP_HOST} ^(subdomain).(site.com)$ [NC] RewriteRule ^file.txt$ /file-%1.txt [L,NC]

Categories : Regex

Htaccess file does not change file extensions
Below I have pasted the url rewriting code necessary to chop off extensions manually, which should be in .htaccess file in the directory of your website that you would like to rewrite the extensions for. RewriteEngine On RewriteRule horses.htm Xu8JuefAtua.htm This simply displays the horses.htm page as Xu8JuefAtua.htm in the address bar. To rewrite a url to not need the file extension and be case insensitive, then this is the code you are looking for: RewriteEngine On RewriteRule ^horses/?$ Xu8JuefAtua.html [NC] The regular expression ^ means the beginning of the URL path, the ? means that the preceding character, in this case a slash in not necessary. The $ matches the end of the url. Smashing Magazine gives a great writeup on the .htaccess file and how to use Regular ex

Categories : HTML

Is there equivalent to O_NONBLOCK when opening a file on Windows?
Do you have any control over the application generating the logfile? Because depending on the way the file is open by that application, you really can't modify it. This link may seem off-topic here, but deep in Windows, what determines the file access to other application is the dwShareMode parameter of the CreateFile function: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx The application should enable FILE_SHARE_WRITE and possibly FILE_SHARE_DELETE, plus it should flush and update the file position everytime it writes a file. Looking at the Python documentation for open(), there is no such detailed parameter.

Categories : Python

Image File Execution Options equivalent on os x
There is no equivalent of that API on OS X. The closest you can come that I'm aware of is using Xcode's "Wait for application to launch" option for debugging, which will fire up the debugger and then attach to the application as soon as it sees it launched. This is also available in both gdb and lldb on the command line, if that's more your thing.

Categories : Xcode

Javascript file object equivalent in java
It depends on what you want to store in your List. You can even choose to use List<?>, which will allow you to store almost anything in it. But if your attachment objects are of type Attachment, I'do go with List<Attachment>. That would allow you to store only Attachment objects in the list. Since in Javascript there are no classes, it might be worth to mention that in Java, every object is an instance of a "class". Sometimes you define classes yourself, sometimes you re-use classes inside a framework or library. So there is no general answer to the question, what type your elements will have.

Categories : Java

Is there a C++ equivalent (or equivalent technique) of Perl's __DATA__ segment?
There’s nothing like that in general. However, the Linux ELF binary format allows the inclusion of data files via the GNU tool objcopy. On Windows you can use resource files and assign the linker to include those in the executable. OS X conventionally uses application bundles to achieve a similar effect.

Categories : C++

Equivalent of "GoTo" in Google Apps Script (equivalent VBA-GAS )
You don't need GoTo, most people would argue that it is terrible programming practice to use it even when it is present. Using other control structures will do the job. if() { } else if() { } else { } for(;;) { continue; break; } while() { } do { } while(); switch() { case: default: } // for errors throw "Error string" try { } catch(error) { } You'll have to shuffle your logic around a bit, but it will result is better more maintainable code.

Categories : Javascript

switch statement equivalent in Windows batch file
This is simpler to read. If it doesn't suit what you need to do then describe it better. IF "%ID%"=="0" REM do something IF "%ID%"=="1" REM do something else IF "%ID%"=="2" REM do another thing IF %ID% GTR 2 REM default case...

Categories : Batch File

How is equivalent align and colspan table's tag in .css style file
Let me elaborate a bit. colspan defines the number of columns a cell should span in a group of columns. Example :DEMO FIDDLE <table border="1"> <tr> <td>Cell A</td> <td>Cell B</td> <td>Cell C</td> </tr> <tr> <td colspan="3">Cell ABC</td> </tr> </td> </table> In this example i have specified colspan="3" for the second row <td>. Hence this <td> will span 3 columns of the table. align is a style attribute which has 3 options left, right, centre. This will determine where you want to place the table on your page. Example: <table align="center"> <tr> <td>Cell A</td> <td>Cell B</td> <td>Cell C&

Categories : HTML

Hibernate mapping file equivalent of referencedColumnsProperty in JoinColumns annotation
I've been working on this same problem. I saw your question before I solved it, figured I would come back here and help you. I'm using 4.2.2. I genericized the names, but I think you will get the point. The "parent" class contains the collection of "child" objects, which means the "child" table has a foreign key constraint to the "parent" table. Pay close attention to the following: 1. The order of the columns in the collection keys must match the order in the composite-id. 2. The attributes on the bag collection are really important. What I have below is working for me. <class name="ParentClass" table="parent_table"> <composite-id name="parentCompositeId" class="ParentCompositeId"> <key-property name="pkName1" column="pk_name_1" type="integer"/> &

Categories : Hibernate

paraview python scripting equivalent of File->save Data
I had a similar problem with pvtu files and solved it with the script below. I run the script using execfile("SCRIPTNAME") in Paraview -> Tools -> Python Shell. I hope this helps. -- Reinhard from paraview.simple import * import os """Function that counts number of files with specific extension in directory """ def directory(path,extension): list_dir = [] list_dir = os.listdir(path) count = 0 for file in list_dir: if file.endswith(extension): # eg: '.txt' count += 1 return count """Choose input/output directory and filenames""" pvtu_input_directory = "thin_1000_0.4/mesh/" csv_output_directory = "thin_1000_0.4/csv/" input_filename_root = "output" output_filename_root = "output" """ Create output directory """ os.system('mkdir '+csv_output_directory) """Start Loop o

Categories : Python

Please take a look at this .htaccess file
This code is faulty and is not going to work: RewriteCond %{HTTP_HOST} www.junkwize.com/home-Garden%20Clearance RewriteRule (.*) http://www.junkwize.com/services/garden-clearance-london [R=301] Reason is that RewriteCond %{HTTP_HOST} can only match host name. Replace that code with this: RewriteRule ^home-Garden Clearance/?$ /services/garden-clearance-london [R=301,L,NC]

Categories : Htaccess

Rewrite file url to different file using htaccess?
You cannot securely hide a css file from the client if you want to use it on at least 1 page. You can use the referer header to redirect to a 404-page if it is not set, but: this header can be spoofed in some cases it is set anyways using developer tools, it would still be visible when viewing the request there You could set up a very smart system that would generate an unique id for every request, and would only show the css file if that id matches an id that is currently authorized to see that page, but: using developer tools, it would still be visible when viewing the request there Your stylesheet is requested from the browser to apply style to your text, and therefore it will always be possible to forge a request with that browser to see the contents of the file (or the output

Categories : Wordpress

Using .htaccess file in Apache
Using .htaccess files slows down Apache. If you can, modify the main server config file (usually called httpd.conf) From the manual: You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance. http://httpd.apache.org/docs/current/howto/htaccess.html. On the other hand if you want to discuss or argue the performance loss versus the loss of ease of maintenance see this post by Simon Greenhill and his benchmarking results.

Categories : Performance

Can Anyone Decipher a .htaccess File?
The redirect is probably being done by wordpress, since a request for a resource that doesn't exist will get trapped by the conditions: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d and the request gets routed through /index.php, which sees that the request is asking for something that's not there and redirects the browser to the root. You can redirect as long as the rules are before any wordpress rules. Not sure why you have so many wordpress blocks that do essentially the exact same thing, you only need one of them. But before any of them, you can add the rule: RewriteCond %{HTTP_HOST} ^YourDomain.com$ [OR] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.html RewriteRule ^(index.html)?$ http://www.YourDomain.com/ [L,R=301]

Categories : Wordpress

How do I re-write this htaccess file?
Here's what you need to do: Change the RewriteBase to the name of your subdirectory Remove the leading slash from the /index.php Place the rules in an htaccess file in your subdirectory. So say your subdirectory is called /subdir and you have http://domain.com/subdir/index.php, you'd have this: RewriteEngine On RewriteBase /subdir/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L,NC,QSA]

Categories : PHP

Rename URL from the htaccess file
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 %{THE_REQUEST} ^[A-Z]{3,}s/+?chapter=1s [NC] RewriteRule ^ /about? [R=302,L] RewriteRule ^about/?$ /?chapter=1 [L,NC,QSA] With above in place now when you try to visit http://site.com/about it will internally forward your request to: http://site.com/?chapter=1 while not changing the URL in the browser (no redirect). When you visit http://site.com/?chapter=1 it will be externally redirected to http://site.com/about .

Categories : PHP

Why is my .htaccess file not redirecting?
If you get internal server error it can be mod_alias disabled. Check your httpd.conf file for line similar to that LoadModule alias_module modules/mod_alias.so. If it does not exist then try adding it.

Categories : Htaccess

Issue with .htaccess file
Create exception for any folder using RewriteCond as follows: RewriteCond %{REQUEST_URI} !^/(event|phpmyadmin)/ [NC] RewriteRule ^ .system/core/index.php [L]

Categories : Regex

i want to rewrite my url from htaccess file
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 RewriteRule ^(testclient)/?$ /$1/123flashchat.swf?init_host=208.98.56.230&init_port=55527 [L,QSA,NC,NE]

Categories : Apache

Is it possible to see .htaccess file of any website?
Access to .htaccess is disabled by Apache config similar to this in httpd.conf: # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # <FilesMatch "^.ht"> Order allow,deny Deny from all Satisfy All </FilesMatch>

Categories : Htaccess

How to remove file name from url using .htaccess?
Store this .htaccess to http://127.1.1.1/mysite/.htaccess: RewriteEngine on /mysite/ RewriteRule ^(.*)$ username/$1 [r=301,L] http://127.1.1.1/mysite/admin -> http://127.1.1.1/mysite/username/admin http://127.1.1.1/mysite/admin.php?some=value -> http://127.1.1.1/mysite/username/admin.php?some=value username.php RewriteEngine on /mysite/ RewriteRule ^(.*)$ username.php?requested-file=$1 [r=301,L] http://127.1.1.1/mysite/admin -> http://127.1.1.1/mysite/username.php?requested-file=admin

Categories : PHP

URL rewriting via my .htaccess file
You can't match against the query string in a RewriteRule statement, you need to use a RewriteCond and the %{QUERY_STRING} variable: RewriteEngine On RewriteCond %{QUERY_STRING} ^id=([0-9]+)$ RewriteRule ^$ /%1? [L] The ? is needed in the rule's target to remove the query string.

Categories : Htaccess

htaccess file not working in php?
I think you got a few things wrong. In the rewrite rule you have $2/3 when it should be $1/2. Plus you have {1,10000} which means min of 1 number to 100000 digits long! You might want to have like {1,6} or whatever your limit is. Also I believe there is a limit on the length of a url which is ~2000 characters long depending on browser/search engine, but its better to keep them shorter! if you want actually 1-10000 you can try: RewriteRule ^([1-9][0-9]{0,3}|10000)-([a-zA-Z0-9_]{1,6})$ news.php?id=$1&namenews=$2 Otherwise: RewriteRule ^([0-9]{1,6})-([a-zA-Z0-9_]{1,6})$ news.php?id=$1&namenews=$2 (----$1----) (-------$2--------) I'm not sure if you have a echo for your a tag but you should do something like: echo '<a href="', $slidefetch->id_ar, '-', $slidef

Categories : PHP

How to include php file in .htaccess?
You can try auto_append_file, as follows php_value auto_append_file "footer.php" That would have the effect of including footer.php after every PHP script, which I think is what you want? There is also auto_prepend_file, which will include the specified script before each request.

Categories : PHP

Rewrite url using .htaccess file
The %{HTTP_HOST} variable is only the hostname, no URL-path info is in it. So you need to remove it and add it to the pattern in your rule: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^magsonwink.winkplatform.com$ [NC] RewriteRule ^/?Shopping/paynow(.*)$ https://magsonwink.winkplatform.com/Shopping/paynow$1 [QSA,R=301,L]

Categories : Apache

How to write .htaccess file
How about this? RewriteRule ^secure/([a-zA-Z0-9]+)/([0-9]+)/([a-zA-Z0-9-_.]+)$ secure.php?hash=$1&timestamp=$2&file=$3 [NC,L] The complete .htaccess file: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^secure/([a-zA-Z0-9]+)/([0-9]+)/([a-zA-Z0-9-_.]+)$ secure.php?hash=$1&timestamp=$2&file=$3 [NC,L] </IfModule> The file should be placed in the webroot of your site.

Categories : Regex

301 redirection in .htaccess file not working
Your redirect statement is part of mod_alias, but all the rest of the rewrite rules you have belong to mod_rewrite. Those two modules processes the request at different points of the processing pipeline, so if you use them concurrently, sometimes they'll not play nicely with each other. You should just use mod_rewrite in this case as well as putting the redirect rule BEFORE your wordpress routing rules. This is because wordpress will route what you actually want to redirect. So: # Use PHP 5.3 AddType application/x-httpd-php53 .php # Redirect www to non-www RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] #### INSERT THE REDIRECTS HERE # Redirects RewriteRule ^oldpage(.*)$ http://domain/newpage$1 [L,R=301] # BEGIN Wo

Categories : Htaccess

create .htaccess file by using php mysql.
Here I found a nice post to for using custom URL. http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/ You can use RewriteRule to generate your required type of URLs.

Categories : PHP

How to Remove the IP canalization using .htaccess file
If that's the only domain that you host from your document root, then you can try adding these rules to the htaccess file in your document root: RewriteEngine on RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www.neotericuk.co.uk$ [NC] RewriteRule (.*) http://www.neotericuk.co.uk/$1 [R=301,L] If there are other hosts that are also being hosted from the same document root, then you can match specifically for the IP address: RewriteCond %{HTTP_HOST} ^neotericuk.co.uk$ [NC,OR] RewriteCond %{HTTP_HOST} ^1.2.3.4$ RewriteRule (.*) http://www.neotericuk.co.uk/$1 [R=301,L] where 1.2.3.4 is your server's IP address.

Categories : Htaccess

htaccess not working cant find file
You need to add the conditions in for each rule, and I'm pretty sure the RewriteRule pattern match requires a slash at the start too. I've assumed the 4 PHP files are in the same directory that your .htaccess file is in. The [L] tells mod_rewrite to stop parsing the .htaccess file for the current request: RewriteEngine On RewriteBase / RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^Download/(.*)/?$ /downloadit.php?key=$1 [L] RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^Buy/(.*)/?$ /buy.php?key=$1 [L] RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f # You've only specified one matching group here, so $2 will be blank RewriteRule ^Admin/(.*)/?$ /admin.php?cmd=$1&key=$2 [L] Re

Categories : PHP

Noob and Newbie for .htaccess file
First one you should find easily online, just by searching "rewrite non-www to www", second one is easy, should be something like this ( might need simple editing, haven't done much apache rewrites since i moved to nginx, edits for fixing are welcome RewriteRule /product/([^/]+)/([^/]+) /product.php?prodtype=$1&prodname=$2 EDIT: Use this link for your first question, guess I'll just paste you a link to see.

Categories : PHP



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