Thousands of 404 errors on old posts due to embedded links

I am about 99% sure the reason for much of this is that someone has used relative links in the post body. A link that looks like this: <a href=”www.whufc.com/”>Some link Test</a> Will end up looking like this: 2010/premiership-forecast-title-race-hots-up-gunners-prepare-for-adebayor/www.whufc.com/ If it shows up on this page of the site: 2010/premiership-forecast-title-race-hots-up-gunners-prepare-for-adebayor/ You need to have the … Read more

Hard to find a good rewriting rule

Rewrite rules are intended to convert ugly urls (containing with & and ?) into pretty urls not the countrary. So I think you need a redirect more than a rewrite rule: add_action(‘after_setup_theme’, ‘my_custom_redirect’, 1); function my_custom_redirect() { if ( filter_input(INPUT_GET, ‘post_type’, FILTER_SANITIZE_STRING) === ‘portfolio’ ) { $cat = filter_input( INPUT_GET, ‘portfolio-category’, FILTER_SANITIZE_STRING ); $tag = … Read more

Custom Structure permalinks error 404

Mehdi, it’s common problem, as Apache server is not set by this way by default. Your problem can be solved with some very simple steps (simply quoting Samuel B): If you want to use permalinks, you will need to make a change inside another file: apache > Conf and find the file httpd.conf. Open that … Read more

Rewrite rule shows 404 page

The index.php you see is not the template file. It is pointed to index.php file you see in the root of your WordPress installation. How does the pretty URL translate into a template file When a person goes to a URL on your site, the .htaccess redirects all requests, that don’t match an actual file, … Read more

Change /search to /somethingelse

Ok, the solution I’m now using is to create a rewrite rule in .htaccess (on the root of wp project) like this: RewriteCond %{QUERY_STRING} ^s=([^\&]*)$ RewriteRule ^(.*)$ /pesquisar/%1 [NE,L,R=301] I don’t know if it’s the best solution but seems to be working ok!

Add rel=canonical to only one page

Check if you are on the front page with is_front_page(). The home page (in WordPress the page with the latest posts) can be checked with is_home(). You can add this to the header.php between <head> and </head>: <?php if ( is_front_page() ) echo ‘<link rel=”canonical” href=”‘ . home_url( “https://wordpress.stackexchange.com/” ) . ‘” />’; ?>

Rewriting a date hierarchy into a ‘yyyy-mm-dd’ slug

Internal rewrite rules have to point to index.php and set the proper query vars for WordPress to be able to load the requested object: add_rewrite_rule( ‘magazine/(\d{4})/(\d{2})/(\d{2})/?’, ‘index.php?issue=$matches[1]-$matches[2]-$matches[3]’, ‘top’ ); That should get incoming requests to resolve correctly, however, that’s only half the task. If you call the_permalink for your posts, you’ll still get the format … Read more

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