w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Redirect non-existing subfolders with .htaccess
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 / RewriteRule ^(search-.+?.htm)/.*$ /$1 [L,R=301,NC]

Categories : Htaccess

htaccess redirect of subfolders within a folder structure
mod_rewrite - change URL case Only that the second answer is the right one. Also, RewriteMap must be in the Server config or VirtualHost My solution for generic use: <VirtualHost *:80> ... <IfModule mod_rewrite.c> RewriteEngine On RewriteMap uppercase int:toupper RewriteRule ^/(en|he)(/.*)?$ /${uppercase:$1}$2 [L,R=301] </IfModule> ... </VirtualHost> So you can add languages separated by | For use with no access to server or virtual host configuration and for specific strings: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^en(/.*)?$ /EN$1 [L,R=301] </IfModule> Remember that in RewriteRule in per-directory (.htaccess is a per-directory setting) setting you omit the first slash on the match pattern. Checked on Apa

Categories : Htaccess

How to ignore subfolders and redirect to the root directory with .htaccess
Remove the second RewriteCond which checks if directory doesn't exist !-d <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /demo/ RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . /demo/index.php [L] </IfModule>

Categories : Htaccess

htaccess redirect with parameters not working correctly
You can use some PHP framework, and it will managed the URL for you. If you want to do it manually you have to configure .htacess file. Try this link. .htaccess friendly URl This kind of question had been asked before.

Categories : Htaccess

Subfolders Url rewriting using htaccess
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 / RewriteRule ^(polo)/(id)/([0-9]+)/?$ /$1/show.php?$2=$3 [L,QSA,NC]

Categories : PHP

Wildcard subdomain and subfolders as parameters in .htaccess
You're missing a QSA flag, as the l=genres gets lost otherwise. You just need an "admin" rule before your other rule: RewriteEngine on RewriteCond %{HTTP_HOST} !^www.mysite.com RewriteCond %{HTTP_HOST} ^(.+).mysite.com RewriteRule ^admin/?$ http://www.mysite.com/app/admin.php?dj=%1 [P,L,QSA] RewriteCond %{HTTP_HOST} !^www.mysite.com RewriteCond %{HTTP_HOST} ^(.+).mysite.com RewriteRule ^([^/]*)$ http://www.mysite.com/app/dj=%1 [P,L,QSA]

Categories : Htaccess

rewrite rule for dynamic subfolders using .htaccess in the root directory
Assuming you need ../index.php?product=bike to be rewritten as ../product/bike/ RewriteCond %{QUERY_STRING} (^|&)product=(.*)(&|$) RewriteRule ^(.*)/index.php$ $1/product/%1? [NC,L]

Categories : Htaccess

.htaccess - redirect all to index.php, but redirect particular link to another
You have two problems here. First, the more specific rewrite rule has to come before the general one. Second, your specific rewrite rule is backwards. RewriteEngine processes rules from top to bottom, much like a programming if/else if/else. This means that you want to put your catch-all case (aka the ^(.*)$) at the bottom of the list. All rules before this need the [L] attribute to stop further processing after they are matched. For the second part, you want to make the browser link http://www.domain.com/link point to the actual file http://www.domain.com/some_real_page.php. In your sample code, you are doing the opposite. The end result should look like this: RewriteEngine on RewriteCond %{REQUEST_URI} ^/link$ RewriteRule ^(.*)$ some_real_page.php [R=302,L] RewriteCond %{REQ

Categories : Htaccess

Redirect using .htaccess to redirect multiple old pages and non-www to www
You must take several steps: Edit the home_url and site_url options for the main sites (in wp_options if your table_prefix is "wp_", as you want to change the urls of your main site). Edit the domain of your main blog in wp_blogs to www.your-domain version Edit wp-config DOMAIN CURRENT SITE like this: define('DOMAIN_CURRENT_SITE', 'www.example.com'); //your new www one! Go to wp-admin of your blog and reset permalinks Your RewriteRule is fine, but you can make it more dynamic to use in other sites like this: RewriteCond %{HTTP_HOST} ^example.com RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] Or, if your host multi-domains into the same network, like this: RewriteCond %{HTTP_HOST} ^(example1|example2|exampleN).com RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=30

Categories : Misc

htaccess RewriteRule, how do should it handle hex codes
After much searching, I found the answer inside another StackOverflow post: How to encode special characters using mod_rewrite & Apache? Thanks for the help.

Categories : Regex

Redirect with .htaccess
This rule will only accept URL with 3 parameters (no less, no more). Each one can contain numbers, letters and - (in other words : [a-zA-Z0-9_-]) RewriteEngine On RewriteBase / RewriteRule ^([w-]+)/([w-]+)/([w-]+).html$ http://myanotherdomain.com/index.php?c=$1&s=$2&p=$3 [L,R=301] You can modify this htaccess to allow 1, 2 OR 3 parameters : RewriteEngine On RewriteBase / RewriteRule ^([w-]+).html$ http://myanotherdomain.com/index.php?c=$1 [L,R=301] RewriteRule ^([w-]+)/([w-]+).html$ http://myanotherdomain.com/index.php?c=$1&s=$2 [L,R=301] RewriteRule ^([w-]+)/([w-]+)/([w-]+).html$ http://myanotherdomain.com/index.php?c=$1&s=$2&p=$3 [L,R=301]

Categories : Htaccess

Redirect one url to another url using .htaccess
RewriteRule doesn't include the query string and doesn't include the http-host. Besides that, the first argument is a regex pattern. Without the http host you would be matching either download/page=download(etc) or downloadpage=download(etc). You'll need 2 rules. One that redirects the ugly url to the nice url. One rule needs to rewrite the nice url to an actual working url: #Rewrite ugly url to nice url RewriteCond %{QUERY_STRING} ^page=download&?(.*)$ RewriteRule ^download/?$ download/show?%1 [R,L] #Now get the nice url to work: RewriteRule ^download/show/?$ download/?page=download [QSA,END] The second rule uses the QSA flag, which means it will append the original query string to the query string in the rewriterule. The END flag stops all rewriting, as the L-flag doesn't do tha

Categories : Apache

Redirect htaccess php
Problem is using $ (end of input) in this regex: RewriteCond %{QUERY_STRING} ^f16%5B0%5D=bla+bla+bla$ Since your query string is: 16%5B0%5D=bla+bla+bla&cPath=72&M_ID=12x Change that line to: RewriteCond %{QUERY_STRING} ^f16%5B0%5D=bla+bla+bla(&|$) Update: Looking at your question I realize that you are using quite a few special characters that need to be escaped. RewriteCond %{QUERY_STRING} ^(f16%5B0%5D)=bla+bla+bla(?:&(.*)|$) [NC] RewriteRule ^(products_filter.php)$ /$1?%1=bla+bla&%2 [L,R=301,NE] PS: It is important to use NE flag here. Otherwise %5B and %5D will be further encoded by Apache.

Categories : Htaccess

404 redirect using .htaccess
ErrorDocument 404 /404.php You can place the 404 error template anywhere you want. For example you could place all error messages in a folder called errormessages ErrorDocument 404 /errormessages/404.php

Categories : Htaccess

.htaccess redirect to url
Remove the second group in brackets and don't escape dots and question mark in the 2-nd part of RewriteRule: RewriteRule ^product/([0-9]+).html$ product.php?id=$1&type=deals [QSA,L] I'm desire to change the url become www.example.com/products/1111.html. I didn't change ^product/ to ^products/, as your php file is called "product.php". But you can do it easily. Now when you input: http://www.example.com/product/1111.html it will be rewritten to: http://www.example.com/product.php?id=1111&type=deals

Categories : PHP

htaccess redirect from /foo/bar/ to foo.php?q=bar
Hello i think i got this but the following appends no query even though its there....if someone can point out...it would be nice. Options +FollowSymLinks +MultiViews RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /dosearch.php?q=(.*) HTTP/ RewriteRule ^dosearch.php$ dosearch/%1? [R=302,L] RewriteRule ^dosearch/([^/]+)? dosearch.php?q=$1 [NC,L]

Categories : PHP

htaccess: How to redirect non-www url to my www-url
RewriteCond %{HTTP_HOST} ^example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] edit: RewriteCond %{HTTP_HOST} !^www. RewriteRule (.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] edit 2 Add URL Rewrite Rule To Wordpress this is not helpful?

Categories : Htaccess

PHP MVC & .htaccess 301 Redirect
The problem seems to be not with the rewrite, but with the ability of your new MVC site to handle this URL. It looks like it can handle: /loans/homeloans but not /loans/homeloans?rt=homeloans.php Try accessing both directly; if the latter doesn't work but the former doesn't, then you know the issue is with the routing configuration of your MVC application.

Categories : PHP

How with an htaccess can I redirect an url to a different one
Add this to the htaccess file in your document root: Redirect 301 /product/1283794 /ecom/product/1283794 Pretty easy isn't it? You should take a look at the mod_alias documentation. It's pretty cut and dry, and obvious.

Categories : Htaccess

How to redirect only www with htaccess
You can have a more generic regex pattern if you know your domain will be XXX.com: RewriteEngine On RewriteCond %{HTTP_HOST} ^[^.]+.com$ [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] Or even better: RewriteEngine On RewriteCond %{HTTP_HOST} ^[^.]+.[a-z]{2,4}$ [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Categories : Htaccess

How to handle jQuery UI sliders correctly?
Looks ilke a bug in the jQuery slider, in this demo the least value of the slider is 1 instead of 0, moving 1 point to right gives the value 0 <strong>Minimum: <var id="slider-min-value"></var></strong> <div id="slider-min" class="slider"></div> and $('#slider-min').slider({ range: 'min', min: 0, max: 49, value: 0, slide: function( event, widget ) { $('#slider-min-value').html( $('#slider-min').slider( 'value' ) ); //newrange(); } });

Categories : Javascript

How to correctly handle startForegrounds two notifications
First off, judging by your description, you might be able to get away with a regular service, recognizing that the out-of-memory killer won't come calling unless things are getting dire on the device and your service has really been running a very long time. That said, if you must make the service foreground, the typical strategy here is to show your progress using the Notification you used when you put your service into the foreground state. Using NotificationManager.notify you can post as many updates to that notification as you like, including adjustments to progress bars via Notification.Builder.setProgress, for example. In this way you only show one notification to the user, and it's the one required by startForeground.

Categories : Android

How handle resources in AngularJS 1.2 correctly?
The problem was the way how i iterate over the response. I changed for(item in items){ for(attr in attributes){ if(items[item][attributes[attr]].toLowerCase().indexOf(filterString) != -1){ matchedItems.push(items[item]); break; } } } to for(var i = 0; i < items.length; i++){ for(attr in attributes){ if(items[i][attributes[attr]].toLowerCase().indexOf(filterString) != -1){ matchedItems.push(items[i]); break; } } } and all works fine. AngularJS take care about the correct length value so i can use it for the for-loop instead of iteration over all values (including all values and $promise and $resolved) in the response.

Categories : Angularjs

How to handle authentication data correctly through the whole app
I have a custom subclass of NSMutableURLRequest where I do all kinds of auth and other stuff specific to my server. I keep a couple of static NSStrings in that module. (It's even a little naughtier than a singleton, but take that singleton advice with a grain of salt...Singletons aren't satanic, they're just discouraged). Sometimes you really need to have just one of something.

Categories : Objective C

How to correctly handle an iterator for upper_bound
Compare these two: The goal is to to find the next element greater than key, so that's why I'm decreasing iter. The reason was some overlapping ranges in the map. Returns an iterator pointing to the first element in the container whose key is considered to go after k That means, upper_bound already does what you need. So don't decrement the iterator. There are three corner cases: The map is empty, then there is only one iterator, namely end()/begin(). Decrement, increment and dereferencing of iter wil give UB. The map contains no value with a key greater than your argument. upper_bound will return end(), so don't dereference it. The map contains only values with keys greater than your argument. upper_bound will return begin(). Your decrement is UB then, but since it's wrong a

Categories : C++

How to handle special characters like & and / in .htaccess rules?
You need to URL encode 'ab&cd' using urlencode so that & gets turned into %26. After this, in search.php you'll need to account for it and decode it, using urldecode.

Categories : PHP

301 Redirect *.php to *.html via .htaccess?
Add this above your RewriteRule ^(.*).html$ $1.php [QSA] rule: RewriteCond %{THE_REQUEST} /(.+).php RewriteRule ^ /%1.html [L,R=301] That will redirect the browser/client to the same request but with a .html instead of a .php.

Categories : Htaccess

Redirect only sub pages using htaccess
I think what you are searching for is a condition that checks if the file that is requested is not a filename. That's what RewriteCond %{REQUEST_FILENAME} !-f. It is true if %{REQUEST_FILENAME} (I believe an absolute path to a file on the server, based on the request), is not a file. (Please note: I haven't tested this code as I don't have access to a server at this location, but I think it should work.) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP_HOST} ^domain.com [NC] RewriteRule ^(.*)$ http://sub.domain.com/$1 [L,R=301] An other solution would be to only rewrite the url if the requested url contains a slash. It would redirect domain.com/folder/index.php, but not domain.com/index.php. RewriteCond %{REQUEST_URI} ^/([^/]+)/(.+)$ RewriteCond %{HTTP_HOST} ^domain.com [NC] Rewr

Categories : Htaccess

How to redirect from subfolder with .htaccess?
If you want the redirection to be transparent i.e. /public remains hidden in the URL, don't do a 301 as it does an external redirect. Use the following RedirectRule instead. RewriteCond %{REQUEST_URI} !/public/ [NC] RedirectRule ^mywebsite/(.*)$ mywebsite/public/$1 [NC,L] This would serve /mywebsite/page.html silently from /mywebsite/public/page.html.

Categories : PHP

htaccess redirect performance
Generally htaccess files will be faster with a small number of rewrites/redirects. Regarding Redirects: 8,000 is not a terribly large number of redirects. Depending on how Apache is running for you, doing this with an htaccess file may end up adding extra memory to each Apache thread since each thread may need to hold the entire list in memory, but this won't be more than a few megs of RAM at most. Memory is cheap nowadays. Do you have severe memory constraints on your server - meaning are you close to paging? The CPU hit for a straight lookup of an in memory hash from Apache will be negligible (assuming the whole thing is stored in memory - so basically assuming you answered "no" to having severe memory constraints on your server). The delay for having to parse a PHP page for each fil

Categories : Htaccess

.htaccess 301 redirect rule
You need to use %{QUERY_STRING} to capture and/or match the query string part of the URL: RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+index.php?eID=tx_cms_showpic [NC] RewriteRule ^ http://mavrica.com/fotogalerije/? [R=301,L]

Categories : Htaccess

Htaccess redirect with query
you forgot the 1 after %, i have also changed the search string so it can be anything instead of just number. RewriteCond %{REQUEST_URI} ^/search/?$ RewriteCond %{QUERY_STRING} ^search=([^&]*)$ RewriteRule ^(.*)$ /search/?rs=%1 [L,R=301]

Categories : Htaccess

Set up of conditional redirect in htaccess
What it does is, checking whether the URI is not exactly /en, since the $ indicates the end of the string right after en. Try this, it checks whether the URI is not exactly /en or /en/ or doesn't start with /en/, and if that's the case it will prepend /en/: RewriteCond %{REQUEST_URI} !^/en(/.*)?$ RewriteRule ^(.*)$ /en/$1 [R=301,L] update Considering the other rules you have in your .htaccess file, it is necessary to have the language rule not match again for the following internal redirect to /index.php..., otherwise you'll end up with an endless loop. There may be better ways to prevent this, however the first thing that comes to my mind would be checking for index.php in the first condition: RewriteCond %{REQUEST_URI} !^/(index.php|en)(/.*)?$ So this will cause the rule not to a

Categories : Htaccess

Cannot make htaccess redirect www to non-www
Try this .htaccess code : RewriteEngine On # Change secretdiary.org/index.php?url=URL to secretdiary.org/URL on the browser's url RewriteCond %{HTTP_HOST} ^secretdiary.org$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?url=$1 [L] # Redirect http://www.secretdiary.org/ to http://secretdiary.org/ RewriteCond %{HTTP_HOST} !^secretdiary.org$ [NC] RewriteRule ^(.*)$ http://secretdiary.org/$1 [R=301] # Add trailing slash / if there's none RewriteRule ^([^/]*)[^/]$ $1/ [R=301,L] I'm not sure for the last rule.

Categories : Apache

htaccess redirect for old site url
On your old site: Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory: RewriteBase / RewriteRule ^(articles/.*)$ /resources/$1 [L,R=301,NC]

Categories : Htaccess

htaccess 301 redirect comes with a querystring
First of all mixing mod_alias and mor_rewrite is not a good idea. Just stick to mod_rewrite since it more powerful and more flexible. Have your rules like this: Options +FollowSymLinks -MultiViews <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^coupon/coupon-codes-for-home-shopping-network.htm$ /coupon/coupon-code-for-hsn.com [L,NC,R=301] RewriteRule ^coupon/coupon-code-for-shopping.hp.com$ /coupon/coupon-codes-for-hp-home-store.htm [L,NC,R=301] RewriteCond %{HTTP_HOST} ^domain.com$ [NC] RewriteRule (.*) http://www.domain.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/coupon/ RewriteRule ^(.*)$ /index.php?url=$1 [L,QSA] </IfModule>

Categories : Htaccess

.htaccess Rewrite URL instead of Redirect
It is possible only if you enable mod_proxy in you Apache config. Once it is enabled you can do: # redirect for the blog link RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^topgearsblog/?$ http://aerogearblog.wordpress.com/ [NC,L,P]

Categories : Htaccess

301 Redirect using .htaccess does not work
Since you're anyway using mod_rewrite its better to replace mod_alias based code to mod_rewrite which is more powerful and flexible. You first Redirect rule isn't working because you're using a query parameter. Replace that rule with this: RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+George-Nelson-Bench-CT3005-EDI6.htm?categoryId=-1s [NC] RewriteRule ^ /proddetail.php?prod=George_Nelson_Bench? [R=301,L]

Categories : Apache

How to redirect urls with htaccess
Have your .htaccess like this: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteRule ^tag/somethig/?$ / [R=301,L,NC] RewriteRule ^index.php$ / [R=301,L,NC]

Categories : Htaccess

How-to .htaccess redirect to www without loosing GET
Your 2nd rule needs 2 flags: QSA - Query String Append L - Last Overall your .htaccess should look like this: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^example.com$ RewriteRule (.*) http://www.example.com/$1 [R=301,L] RewriteRule ^catalog/([^/]+)/?$ catalog.php?id=$1 [L,QSA,NC] QSA flag in 2nd rule will make sure to presserve any existing query string while adding a new query parameter id

Categories : PHP



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