How do I redirect to a non-www version and make it the default URL?

This process can be broken into 2 steps: Using .htaccess for Redirection First, you should redirect any traffic from www to non-www version of your website, by using a simple rewrite rule: RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] This … Read more

optimize wordpress rewrite rule regex

With all part optional with ?, you obtain one rule to rule them all : add_rewrite_rule( ‘^cities/(.*)/(browse)?/?(.*)?/?(.*)?/?(.*)?/?(.*)?/?’, ‘index.php?city_name=$matches[1]&cat_name[]=$matches[3]&cat_name[]=$matches[4]&cat_name[]=$matches[5]’, ‘top’ ); but the [] cannot work with the WordPress logic then you need to define the rewrite tag with a number. try that : add_rewrite_tag(“%cat_name.%”, “([^&]+)”); add_rewrite_rule( ‘^cities/([^/]*)/(browse)?/?([^/]*)?/?(^/)?/?([^/]*)?/?([^/]*)?/?’, ‘index.php?city_name=$matches[1]&cat_name1=$matches[3]&cat_name2=$matches[4]&cat_name3=$matches[5]’, ‘top’ );

WordPress .htaccess blocks mine?

Try resetting the default error document at the start of your .htaccess file: ErrorDocument 410 default If you have a custom 410 error document defined elsewhere in your server config then this could end up being routed by WordPress. (I’ve encountered some shared hosts that (for some reason) define a custom “default” ErrorDocument in the … Read more

Url Rewriting a dynamic wordpress page

thanks for you reply, So after much digging, it’s working : function myplugin_rewrite_tag_rule() { add_rewrite_tag( ‘%symbol%’, ‘([a-zA-Z0-9_]+)’ ); add_rewrite_rule( ‘^crypto-monnaies/([a-zA-Z0-9_]+)/?$’, ‘index.php? pagename=showcoin&symbol=$matches[1]’,’top’ ); } add_action(‘init’, ‘myplugin_rewrite_tag_rule’); function add_query_vars( $query_vars ) { $query_vars[] = ‘symbol’; return $query_vars; } add_filter( ‘query_vars’, ‘add_query_vars’ ); Please note that if you dynamic page is a second level page, you have … Read more

How to use URL structure to call PHP code

I assume alan-walker is just an example and this could be any string of this form. (Or is it literally just “alan-walker”, as in you example?) You can do this with a single RewriteRule in .htaccess before the WordPress front-controller. For example: RewriteRule ^directory/([a-z-]+)$ /directory.php?s=$1 [L] This will rewrite /directory/<something> to /directory.php?s=<something>, where <something> consists … Read more

NextGEN Gallery Lightbox – Social Share URL Redirect

You could do something like the following in .htaccess before the existing WordPress directives. RewriteCond %{QUERY_STRING} ^uri=(/[^&]+) RewriteRule ^nextgen-share/(\d+/\d+)/full$ %1#gallery/$1 [QSD,NE,R,L] The RewriteRule pattern only matches against the URL-path, so you need the preceding RewriteCond directive in order to match the query string portion of the URL. If the /121212/8989/ part always consists of 6 … Read more

Problem with add_rewrite_rule

You’re missing the WP $matches[1] syntax for the regex that gets matched. I think you want /? on the end too. Easiest way I found to test was to temporarily put flush_rewrite_rules() in whilst testing, then you don’t have to do anything else. I have a similar regex which sends /foo/catname/ to index.php?taxonomy=category&term=catname, here’s what … Read more

Access files at new location using old file paths

I believe I’ve found the solution. I add the following RewriteRule ^example_directory/files/(.*) new_directory/$1 to my WordPress .htaccess rules like so: RewriteEngine On RewriteBase / RewriteRule ^example_directory/files/(.*) new_directory/$1 RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] I couldn’t get it working before and I think the key was moving the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)