wordpress iis6 permalink /%postname%/ doesnt work IIRF url rewrite needed? - wordpress

I have a wordpress site on iis6 and I want this:php?id=6 to look like this: /postname/. When I change the permalink I get a 404 error. I have the IIRF proxy extension enabled, and in my root directory I have a IIRF.ini with the following code:
RedirectRule ^/blog/index\.php/(.*)$ /blog/$1 [I,R=301]
RewriteRule ^/blog/(?!index\.php|wp-|xmlrpc)(.*)$ /blog/index.php/$1 [I,L]
Is this code incorrect for a permalink of just /%postname%/?
Thanks

I just installed IIRF 2.1 on Windows Server 2003 running IIS6.
Your address seems to have /blog/ on the very beginning, but I'm afraid we can do it simpler. Bellow, follow my whole Iirf.ini, with a simple permalink working:
# Iirf.ini
#
# ini file for IIRF
#
RewriteEngine ON
StatusInquiry ON
IterationLimit 5
# this will allow ugly URLs to not be processed at all
RewriteRule ^/(?!index.php)(?!wp)([^\.]*)$ /index.php/$1 [I]
Make sure this simple form works, and then add /blog/.
Some literature that may help (it helped me)
http://cheeso.members.winisp.net/Iirf21Help/html/49492102-e623-40d7-9dc3-d1411800be80.htm
http://codehill.com/2009/11/wordpress-permalinks-in-windows-using-iirf/
Cheers!

Related

.htaccess rewrite domain.com/en/multisite to domain.com/multisite/en

I'm using multisite WordPress and qTranslateX plugin. My default website is in Bahasa and my second language is English. When I use custom link in mode language English like mydomain.com/multisite, it always added by "en" after mydomain.com, it will be mydomain.com/en/multisite. That link always return 404 because there is no page.
I want to use .htaccess to rewrite URL form mydomain.com/en/multisite to mydomain.com/multisite/en .
Thanks in advance
Unfortunately, you can't achieve that with mod_rewrite alone as far as I know.
Wordpress will look at the REQUEST_URI to figure out what to show, and that one won't be overwritten (and [E=REQUEST_URI:...] will make it $_SERVER["REDIRECT_REDIRECT_REQUEST_URI"]).
If mod_proxy is installed as well, you could do something like this:
RewriteEngine On
RewriteBase /
RewriteRule ^en/([^/]+)(/?.*)$ /$1/en$2 [P,L]
It will proxy the request internally on the same host and server.
Requesting http://example.org/en/test will look to wordpress as if http://example.org/test/en was requested.
Give it a try. If mod_proxy isn't installed, it won't work (and render a 404 for the URL), but it won't break your site, so it's pretty safe to experiment with.

Wordpress REST API (wp-api) 404 Error: Cannot access the WordPress REST API

I have been using the Wordpress REST plugin WP-API for months now while developing locally with XAMPP. I recently migrated my site to an EC2 instance and everything is working fine except I now get a 404 with the following message whenever I try to access any endpoint on the API:
The requested URL /wordpress/wp-json/ was not found on this server
Pretty permalinks are enabled with the following structure http://.../wordpress/sample-post/ which works fine when navigating to a specific post in the browser.
Here are some details about my setup:
Wordpress 4.4.1
Not a Multisite
WP REST API plugin 2.0-beta9
Apache 2.2.22
Ubuntu 12.04.5
Any help would be greatly appreciated as I have gone through SO and the WP Support forums for several hours and am out of ideas. Thank you!
UPDATED NEW WAY
I also faced similar problem in a local project. I used index.php after my project url and it worked.
http://localhost/myproject/index.php/wp-json/wp/v2/posts
If it displays a 404 error then update permalinks first (see "Paged Navigation Doesn't Work" section
If it works, maybe you need to enable mod_rewrite, on ubuntu:
a2enmod rewrite
sudo service apache2 restart
Installation
The REST API is included in WordPress 4.7! Plugins are no longer required, just install the latest version of WordPress and you're ready to go.
If you're before 4.7:
Download plugin from here: http://v2.wp-api.org/
install and activate it.
Usage
To get all posts:
www.mysite.com/wp-json/wp/v2/posts
For the search functionality, searching for test post looks like this:
/wp-json/wp/v2/posts?filter[s]=test
I had this problem with the latest WordPress 4.7+. In my case the REST API only worked after I changed the permalinks setting to something other than "Plain", which was the default setting for my installation.
On WPEngine and WP 4.9.2 I only had to update permalinks to get fresh, newly installed site to return v2 API calls. What I did:
Create site
Browse to http://yoursitename.wpengine.com/wp-json/wp/v2/posts
get 404
Go to admin, settings, permalinks, choose "Post Name"
Click "Save Changes"
Browse to http://yoursitename.wpengine.com/wp-json/wp/v2/posts
success. page displays JSON response
It turned out to be a problem with the Apache configuration.
First, I deleted the .htaccess file in the root wordpress directory.
Next, I navigated to /etc/apache2/sites-enabled and opened 000-default
All of the AllowOverride variables were set to None, which I replaced with All.
That did the trick!
It is the file permission error, apply the following solution:
Edit this file /etc/apache2/apache2.conf
Change /var/www/ Permissions from "None" to "All"
Restart the apache2 server.
First you've to Check if the WordPress REST API is enabled or not
The best way to check is to visit this URL: https://yoursite.com/wp-json.
If you see some JSON response, REST API is enabled.
If it’s showing some error page or returns to home page, REST API is not enabled. Then we've to enable it first.
In this case, you've to Enable Permalinks
Visit your page's admin page (Visit https://yoursite.com/wp-json)
settings > Permalinks (visit https://yoursite.com/wp-admin/options-permalink.php)
Make sure Plain is not selected
Choose Post Name (it's a best one)
Then click on Save Changes. That will rewrite/repair your .htaccess
Please see the helping screenshots below:
Source
I solved this issue through following steps:
Navigate to ..\Apache24\conf\httpd.conf and search for LoadModule rewrite_module modules/mod_rewrite.so.
Enable rewrite module by removing the # mark.
Replace all the cases of AllowOverride None to AllowOverride All.
Don't forget to restart apache server. :)
Adding "AllowOverride All" (as hinted by other authors before) to my apache virtual host configuration on my Ubuntu server via SSH did the trick for me:
sudo vi /etc/apache2/sites-available/my-website-name.com.conf
and also (if you use letsencrypt):
sudo vi /etc/apache2/sites-available/my-website-name.com-le-ssl.conf
The files should then look like:
<VirtualHost *:80>
# or <VirtualHost *:443> for the SSL configuration
# [...]
DocumentRoot /var/www/my-website-name.com/public_html
<Directory "/var/www/my-website-name.com/public_html">
# this allows .htaccess files (e.g. generated by Wordpress)
# to overwrite the apache configuration on a directory basis:
AllowOverride All
</Directory>
# [...]
</VirtualHost>
Don't forget to disable and re-enable the site and reload apache to apply the new configuration:
sudo a2dissite my-website-name.com.conf
sudo a2dissite my-website-name.com-le-ssl.conf
sudo a2ensite my-website-name.com.conf
sudo a2ensite my-website-name.com-le-ssl.conf
sudo service apache2 reload
I had to manually make a .htaccess, set it to chmod 664, and copy the permalink rules into it.
I also played around with
Settings > Permalinks
Manually updating .htaccess via the code at the bottom of the permalinks page after clicked "Save"
Adding "index.php" as one of the other answers suggests
Making sure mod rewrite was enabled via a2enmod
I found that mysite/wp-json/ was not working, but mysite/?rest_route=/ was normal. This was breaking some, but not all, the REST API features used on my site.
The answer to this turned out to be a recent change to how I was running my server. This had broken REST API but this was not apparent until later.
I had changed this domain from using Apache to using nginx, and I had not correctly transferred the .htaccess customisations. The quick solution to this problem was therefore to change back to using Apache. This restored the site to working order immediately.
I will be changing this domain back to nginx in the future but when I do, I will test it and be careful not to affect the REST API.
I had moved the WordPress install from a subdirectory to another, so in my case the problem was due to the WordPress config in the .htaccess files. It was trying to redirect every page but the homepage to the old directory. It was just a matter of updating olddir to newdir...
This tripped me up more than once so I thought I'd put it here...
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /olddir/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /olddir/index.php [L]
</IfModule>
# END WordPress
I faced the same problem when I migrated my site from cPanel to Google Cloud Compute Engine Instance; problem was of file permissions which was initially caused due to difference in PHP versions of current deployment from previous deployment.
Here is the fix How to deal with GCP WordPress error "This page isn’t working example.com is currently unable to handle this request. HTTP ERROR 500
If you website is https://example.wordpress.com (on wordpress) for example, use the below link which will give you the JSON response irrespective of any API settings/Permalinks etc..
https://public-api.wordpress.com/rest/v1.1/sites/example.wordpress.com/posts
If you want to see all the available endpoints use this -
https://developer.wordpress.com/docs/api/console/
Remember to replace **$site** with your domain
Find the latest documentation here -
https://developer.wordpress.com/docs/api/
If you are on Windows OS change the Permalink Settings as follows:
Custom structure: /index.php/%postname%/
I was facing same issue on localhost and I solved this issue with just set RewriteBase Path in .htaccess file which is available at root folder of WordPress project setup.
**Example:**
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /[folder-name]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /[folder-name]/index.php [L]
</IfModule>
If you have tried the other solutions on this page and they haven't worked, I had success with checking for additional .htaccess files in the root folder above your public_html folder (or wherever you have installed WordPress).
I found an extra one which may have come from a previous installation or been accidentally moved there - it was giving conflicting instructions to the 'real' .htaccess file. Deleting it fixed the problem for me.
For me on new website I didn't had Nginx pretty links setting enabled I add this tolocation / block
try_files $uri $uri/ /index.php?$args;
Try to remove any
order deny,allow
deny from all
allow from ...
from you .htaccess.
I read through a whole bunch of articles and eventually discovered there was a force site to be https plugin installed and activated on my local, however there is no certificate set up. It was making the requests for https when I should have had the https plugin deactivated.
Once deactivated, I was able to make connections to REST API.
Not a very in depth answer but it is was my answer. Hope this saves someone some time!
On WordPress 6
You can use this URL and no need for URL Rewrite and no need to change your Permalink settings (I saw Gutenberg editor is using this URL to access REST)
http://example.com/index.php?rest_route=/wp/v2/posts

static to static url rewrite with htaccess with wordpress

I have a wordpress site with its own .htaccess automatically generated (because I'm using permalinks), than, my web-admin has configured apache to redirect any third level domain to my site, ie :
http://lol.example.com redirects to http://example.com
and than .htaccess with permalinks rules does the rest.
Now I want to write a rule in the .htaccess file that, when a user types a specific third level domain, redirects to a specific subfolder of my site, ie:
http://sprock.example.com/ redirects to http://example.com/mysprockfolder/
I know my question might sound weird, but I've never done this before so I'm quite confused.
Solved with that regex in my .htaccess:
Right before this comment (just in case you have WordPress installed):
# BEGIN WordPress
I've added the following:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?thirdlev\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/myfolder/ [R=302,L]
with a 302 redirect, everything is good!
it would be much easier for you to just go to your ftp manager and make a subdomain forward to a link. Or, you can make a redirect using php.
when redirecting make sure to add the http://www. or it will think you want to redirect to a part of your page on the site, also make sure that your subdomain has its own folder with its own files and images.

Running Wordpress in a subdirectory (not the root)

I have a wordpress site that is currently running in a subdirectory of my website, basically put my structure is as follows:
root/wp
I'd like to keep the wordpress wp folder in the same place however have it load the wordpress site directly from the root url.
For instance currently the site loads when I go to www.mysite.com/wp however I'd like to have the wordpress site load when I simply go to www.mysite.com - currently if I go to www.mysite.com it simply loads an 500 Internal Server Error message.
I would expect I'd need to make some changes to the htaccess files - can anyone suggest how this would be done
So in a nutshell
When I go to www.mysite.com - it looks at the /wp folder but still appears as www.mysite.com in the address bar.
Adding these lines to .htaccess should do the job (not tested, sorry, it may not be sufficient):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ wp [L]
Update: You might wish to check https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory for a way to accomplish this that's closer to WordPress standards.

xampp server http://localhost/ redirects to http://www.localhost/ and doesn't work

I have a drupal website and have been using an XAMPP local server; I have several sites on the server and this morning they all worked fine.
On my main site Site 1, I was getting duplicate sites, google was finding http://www.site1.com and http://site1.com, so I edited the .htaccess file as follows:
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
I removed the # from the last 2 lines and uploaded my site.
Hey presto, no more duplicate site on google, however now when I try and log in to my local server instead of it going to http://localhost/site1 it tries to link to http://www.localhost/site1 instead and I get an error saying
Oops! Internet Explorer could not find www.localhost.
My other sites still work fine which suggests it was something to do with the redirect. I have changed the .htaccess file back but it makes no difference.
I have scoured the web with little luck. I have tried changing local host for 127.0.0.1, but I still get the same message.
I'm a newbie and have been tearing my hair out for days now, to no avail. Can someone please help?
Rules related to rewriting of non www to www urls have been turned on .
Commenting those lines should do the trick. Try clearing your browser cache or try from new browser.

Resources