How to redirect single URL in Nginx?

I’m in the process of reorganizing URL structure. I need to setup redirect rules for specific URLs – I’m using Nginx. Basically Something like this: http://example.com/issue1 –> http://example.com/shop/issues/custom_issue_name1 http://example.com/issue2 –> http://example.com/shop/issues/custom_issue_name2 http://example.com/issue3 –> http://example.com/shop/issues/custom_issue_name3 Thanks! Answer location ~ /issue([0-9]+) { return 301 http://example.com/shop/issues/custom_isse_name$1; } AttributionSource : Link , Question Author : tokmak , Answer Author … Read more

How to redirect a URL in Nginx

I need to redirect every http://test.com request to http://www.test.com. How can this be done. In the server block I tried adding rewrite ^/(.*) http://www.test.com/$1 permanent; but in browser it says The page isn’t redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. … Read more

How do I configure IIS for URL Rewriting an AngularJS application in HTML5 mode?

I have the AngularJS seed project and I’ve added $locationProvider.html5Mode(true).hashPrefix(‘!’); to the app.js file. I want to configure IIS 7 to route all requests to http://localhost/app/index.html so that this works for me. How do I do this? Update: I’ve just discovered, downloaded and installed the IIS URL Rewrite module, hoping this will make it easy … Read more

URL rewriting with PHP

I have a URL that looks like: url.com/picture.php?id=51 How would I go about converting that URL to: picture.php/Some-text-goes-here/51 I think WordPress does the same. How do I go about making friendly URLs in PHP? Answer You can essentially do this 2 ways: The .htaccess route with mod_rewrite Add a file called .htaccess in your root … Read more

.htaccess mod_rewrite – how to exclude directory from rewrite rule

I have 8 lines of rewrite rules in my .htaccess file. I need to exclude two physical directories on my server from these rules, so they can become accessible. For now all requests are sent to index.php file. Directories to exclude: “admin” and “user”. So http requests: http://www.domain.com/admin/ should not be passed to index.php file. … Read more

Generic htaccess redirect www to non-www

I would like to redirect www.example.com to example.com. The following htaccess code makes this happen: RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] But, is there a way to do this in a generic fashion without hardcoding the domain name? Answer RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] Same as … Read more

How do I modify the URL without reloading the page?

Is there a way I can modify the URL of the current page without reloading the page? I would like to access the portion before the # hash if possible. I only need to change the portion after the domain, so it’s not like I’m violating cross-domain policies. window.location.href = “www.mysite.com/page2.php”; // Sadly this reloads … Read more

Pagination on custom post type not working

I’m having a hard time getting pagination to work with my custom post type query. The standard “previous_posts_link()” and “next_posts_link();” aren’t working. And through a bit of testing, I’ve noticed neither “get_query_var(‘page’)” or “get_query_var(‘paged’)” are working. Also, adding “/page/2/”, “/2/”, or “/?page=2” isn’t finding a page. Any suggestions? if ( get_query_var(‘paged’) ) { $paged = … Read more