Articles of mod rewrite

WordPress Page Not Found if Permalink Settings is Postname

Uploaded code on staging server. in localhost everything is working well but on staging I can login to admin pabel but can not see any page on frontend. When any page is accessed it says The requested URL /projectname/testpage was not found on this server.. PHP version on localhost is 5.4.3 while on staging is […]

Permalinks not working in WordPress

In wordpress I’ve chosen “Day and name” for permanlinks but I am getting 404. The modrewrite module is loaded, the .htaccess is -rwxrwxrwx 1 www-data www-data 274 nov. 23 13:10 .htaccess i have put htaccess to 777 temporarily just to solve the problem but still it doesn’t work any suggestion ?

.htaccess Non-'www' to 'www' Subdomain Redirection Only Works for Homepage

I would like a WordPress site to redirect all URLs to the www subdomain. Using the .htaccess configuration below, the homepage is properly redirected (i.e. visiting example.com/ redirects to www.example.com/) but internal pages aren’t getting redirected (both www.example.com/page and example.com/page resolve and display the same content). # Redirect non-www traffic to www RewriteEngine On RewriteCond […]

Add additional non-rewrite .htaccess directives on multisites via mod_rewrite_rules filter

According to the example on Adding your own .htaccess contents via WordPress it’s possible to extend the .htaccess file via theme/plugin. for example: <?php function my_htaccess_contents( $rules ) { $my_content = <<<EOD \n # BEGIN My Added Content # Protect wpconfig.php <Files wp-config.php> Order Allow,Deny Deny from all </Files> # END My Added Content\n EOD; […]

WordPress rewrite does not work for some reason

I am learning how to use WordPress rewrites. As a start i am just trying to redirect any request for “validate_data.php” to “validate-data“. Here is what i have added to the functions.php file: function custom_rewrite_basic() { add_rewrite_rule( ‘validate_data.php’, ‘validate-data’, ‘top’ ); } add_action( ‘init’, ‘custom_rewrite_basic’ ); I know i can execute this in the .htaccess […]

Remove base slug in permalinks of hierarchical custom post type

I have a hierarchical Custom Post Type called project, registered as follows: register_post_type( ‘project’, array( ‘public’ => true, ‘hierarchical’ => true, ‘rewrite’ => array( ‘with_front’ => false ) ) ); The URLs currently look like this: https://example.com/project/hello https://example.com/project/hello/world I would like the URLs to look like this: https://example.com/hello https://example.com/hello/world How can I most efficiently accomplish […]

force www rewrite if wordpress put in a folder

My wordspress site is installed in myfolder and it auto create the code in htaccess # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /myfolder/ RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /myfolder/index.php [L] </IfModule> # END WordPress Now I would like to force www to all my links and find […]

WordPress and Htaccess

Removing RewriteBase / from my htacess has sped up my site which is still working correctly. Is it really required and what is it for?

Can't get permalinks working!

I can’t get WordPress pretty permalinks to work on my Fedora LAMP server. If I set them and click a page/post link I’ll get a “”Oops! This link appears to be broken.” The .htaccess file is writable and being updated, mod_rewrite module seems to be loaded in my httpd.conf (See below) The errors in my […]

Disable category RSS Feeds on WordPress blog with PHP

I have a WordPress powered site and I would like to know how to disable all category based RSS feeds with PHP or even mod-rewrite if possible. Thanks