Tag Info

Hot answers tagged

13

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


6

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


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

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

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

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() { ...


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

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

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

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


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

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

'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

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

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

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


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

I apologize this should be a comment. You have to ask yourself if its necessary. I know your asking here for advice, but is your website currently under performing? Is it slow? Are users complaining? I personally wouldn't recommend FastCGI but there are various other plugins or tools to speed up your website. I would recommend the following plugins: ...


1

# Only allow access to this directory if they are coming from your domain; excluding you, your server, Google and any other IPs RewriteEngine On RewriteCond %{REMOTE_ADDR} !^(xxx\.xxx\.xxx\.xxx|xxx\.xxx\xxx\.xxx|66\.249\.) RewriteCond %{HTTP_HOST} !^(127\.0\.0\.0|localhost) [NC] RewriteCond %{HTTP_REFERER} !^https?://(.+\.)?yourdomain\.com/ [NC] RewriteRule ...


1

Its not good way to edit .htaccess for wordpress url rewriting (only for main urls settings from admin panel) You found your response here : API basic url rewriting or The Rewrite API: Post Types & Taxonomies An example : add_action( 'init', 'rewrite_rule' ); function rewrite_rule() { global $wp,$wp_rewrite; // Remember to flush the rules once ...


1

Problem 1 Your hook ci_add_rules() will still run when you flush rules, so remove it first (and avoid "unsetting" non_wp_rules, you'll break other plugins that make use of it). function ci_remove_rules() { remove_action( 'generate_rewrite_rules', 'ci_add_rules' ); $GLOBALS['wp_rewrite']->flush_rules(); } Problem 2 Pretty sure you want: ...


1

This is fairly easy to set up using virtual host configurations in Apache or Nginx (depending on which webserver you want to run on your box). Here's the gist of things: 1. Each installation will have a separate database and separate database user (for security). I set these up manually in MySQL through the command line, but if you have phpMyAdmin set up, ...


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



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