Tag Info

Hot answers tagged

16

Add this to your theme's functions.php, or put it in a plugin. add_action( 'init', 'wpse26388_rewrites_init' ); function wpse26388_rewrites_init(){ add_rewrite_rule( 'properties/([0-9]+)/?$', 'index.php?pagename=properties&property_id=$matches[1]', 'top' ); } add_filter( 'query_vars', 'wpse26388_query_vars' ); function ...


7

Check out the Roots WordPress Theme. They seem to do exactly what you want with the URLs. Here's a snippet from their roots-htaccess.php file: add_action('generate_rewrite_rules', 'roots_add_rewrites'); function roots_add_rewrites($content) { $theme_name = next(explode('/themes/', get_stylesheet_directory())); global $wp_rewrite; ...


6

You can also set a custom variable inside WordPress when your URL is accessed. You can then later check for this variable and if it exists, do whatever you want to do. In this example, we will use wpse6891_stats as our variable. // Register a URL that will set this variable to true add_action( 'init', 'wpse6891_init' ); function wpse6891_init() { ...


6

Hi @NetConstructor: Well if I had thought about how much work with was going to be before writing it, you wouldn't be able to get me points right now. :) Needless to say, it's rather involved (though I don't think it really should have to be, but it is what it is.) First off, you can't (easily) do it like you wanted; the problem is how to differentiate ...


5

Mark, I hate to say it, but you're going about this the wrong way. PHP files in your plug-in should never be accessed directly in this way. Instead, they should be loaded from within WordPress just like everything else. Here are some alternative paths you could take: Create an admin page that displays your stats This is a page accessible from within ...


5

Problem solved. The plugin "User Access Manager" was found guilty of inserting a .htaccess file into wp-content/uploads/ and not handling calls properly afterwards. I don't know how UAM plugin could be fixed, but It's ok to remove the .htaccess file. Nothing else depends on it. (at least in my case)


5

Why don't you create a shortcode for that in the following manner. function img_folder_shortcode( ) { return get_stylesheet_directory_uri() . '/images'; } add_shortcode( 'img_folder', 'img_folder_shortcode' ); And then use the following shortcode anywhere in the content area. [img_folder]/img.jpg <img src="[img_folder]/img.jpg" alt="img" />


5

If the issue is only with images, but not css or javascript, I think there's a typo in your RewriteRule. I think your missing a "1" after the "$": RewriteRule ^images/(.*)$ wp-content/themes/standard/images/$1 [L] Also, you might want to try putting those extra statements below the initial rule, ie below this line: RewriteRule ^index\.php$ - [L] Not ...


5

Have a read of the following thread on the WordPress forum, apparently the AddThis plugin is the reason the hash tag is been appended to the URL. http://wordpress.org/support/topic/random-hashtag-strings-added-to-url-in-firefox


5

You'll find this post by Joost De Valk on changing WordPress permalinks to only include /%postname% very helpful. How many posts you have doesn't matter anymore if you are using the latest version of WordPress (at least > v3.3.1). I believe your permalink structure initially was — this /blog/%year%/%monthnum%/%day%/%postname%/ — and now, you are planning ...


4

The output of $_SERVER['SERVER_SOFTWARE'] is WebServerX That looks like your problem - check out this line in wp-includes/vars.php: /** * Whether the server software is Apache or something else * @global bool $is_apache */ $is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== ...


4

In theory, you could rename the file and change the rewrite rule accordingly. Assuming you rename it to wp-index.php, it would look something like this: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wp-index.php [L] </IfModule> There are a few ...


4

You don't have to touch the Apache configuration for this, you can do this all from the WordPress rewrite system. But indeed, your general idea is correct: you should append ?cat=3 (or category_name=blog if you want to be even clearer). Remember that your blog archive can have multiple pages, maybe you want to handle this too. This is how I would do this ...


4

you need 3 simple functions and hooks first change the author base: //change author/username base to users/userID function change_author_permalinks() { global $wp_rewrite; // Change the value of the author permalink base to whatever you want here $wp_rewrite->author_base = 'users'; $wp_rewrite->flush_rules(); } ...


3

WP rewrite rules are not real rewrites nor will they allow redirects like that. So you can't use them that way. Fortunately, WP should have you covered there even if you try. See, an internal WordPress rewrite rule must change a URL pattern into an index.php?key=value pattern. So when you use add_rewrite_rule to insert a rule that doesn't point to the ...


2

If your permalink structure is /%postname%/ with a trailing slash, you need to pass the hash like this: /faqs/#b with the trailing slash.


2

The URL hash (everything after the #) does not get sent to the server, so Apache or WordPress can't detect it. WordPress redirects all URLs to the canonical version of the URL, to make sure everyone uses the same URL when linking to a post (which can help increase your ranking in search engines). This causes a redirect from /faqs to /faqs/. Browsers should ...


2

yes, this: https?://yoursite.com doesn't do anything you want, just make it http://yoursite.com. Next to that, make sure your server actually supports RedirectMatch.


2

'RewriteBase /' is not needed. RewriteBase allows you to change your internal directory structure to something other than what a browser sees. IE: If all your files are in 'http://mydomain.com/site', but you wanted 'http://mydomain.com' to be the path browsers see, you would use a RewriteBase /site and apache's mod_rewrite would happily add that substitution ...


2

No, index.php file is present and used in WordPress (source). Depending on what existing homepage is it can be renamed to another non-conflicting file or migrated to WordPress.


2

I did not test this, but this should do what you want. Put the following in your functions.php: add_filter('rewrite_rules_array', 'new_category_name_rewrite_rule'); function new_category_name_rewrite_rule($rules) { $new_rules = array(); $categories = get_categories(); foreach ($categories as $category) { $cat_name = preg_replace('#\s+#', ...


2

Alternatively you can add the following line of code to your functions.php file: add_filter( 'got_rewrite', '__return_true', 999 ); We're doing this to make WordPress play well with nginx.


2

The best way to accomplish this is remove the default sanitize_title filter and replace it with yours, which will encode those characters properly. Here is an implementation of using accents in permalinks. Example: remove_filter( 'sanitize_title', 'sanitize_title_with_dashes'); add_filter( 'sanitize_title', 'restore_raw_title', 9, 3 ); function ...


2

This should cover everything: function wpa_rewite_translate(){ global $wp_rewrite; $wp_rewrite->pagination_base = 'pagina'; $wp_rewrite->author_base = 'autor'; $wp_rewrite->comments_base = 'comentarios'; $wp_rewrite->feed_base = 'alimentar'; $wp_rewrite->search_base = 'busqueda'; ...


2

Inside of your config you have the following: <Directory /> Options FollowSymLinks AllowOverride None </Directory> You should change it to the following: <Directory /> Options FollowSymLinks AllowOverride All </Directory> The AllowOverride directive is what allows the .htaccess file to be read. If you still have ...


1

RewriteCond %{HTTP_HOST} dom1 [NC] RewriteRule ^((about\-us|etc).*) /dom1/$1 [NC,QSA,L] Your rewrite rule includes the L parameter, which makes it stop processing rewrites. So WordPress's rules to redirect to index.php likely never come into effect. Which means WordPress is not even being run here. The 404 is likely from the webserver saying that the file ...


1

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 ...


1

If you don't want Wordpress to overwrite your changes in .htaccess file, then make sure that you write your changes outside of the Wordpress comment block, that is, either before or after this: # BEGIN WordPress ... # END WordPress Think of this area as Wordpress' territory. Anything within this block, will be overwritten by Wordpress once it has to make ...


1

This is currently not possible for a multisite setup. It should be possible in WordPress 3.5 which is planned to be released next month. So your only solution is: wait. Update December 26: This is now possible in WordPress 3.5 without further hacks. :)



Only top voted, non community-wiki answers of a minimum length are eligible