.htaccess and proxy settings for routing a decoupled REST API consuming theme

Developing a decoupled front-end consuming the REST API... I'm using create-react-app so can enter a proxy field corresponding to WP in my package.json and write my calls like fetch('/wp-json/v2/pages/...') if I run yarn start from the front-end directory... I'd love to actually have this theme in my wp-content/themes/my-theme directory though I'm no .htaccess god How can I make so that: Generic requests like mysite.com/jibble/jabble are handled by my SPA routing Protected routes like mysite.com/wp-admin/* and mysite.com/wp-content/uploads/* are still handled by …
Category: Web

Redirect htaccess does not work correctly with my new wordpress site

I have an old website that works fine (www.example.com). I have created a new website (www.example.com/wordpress) and I thought I could use .htaccess to redirect as I've done it for other html websites in the past. I get the result: www.example.com/worpress/wordpress/wordpress......... until it's in error. Can someone help me? I used this command in .htaccess: Redirect permanent / http://www.example.com/wordpress/
Category: Web

How do I add /blog/ as a prefix to permalink structure for posts, categories & tags?

The URL structure I am hoping for is as follows: All posts: /blog/ and /blog/page/2 Categories: /blog/%category%/ and /blog/%category%/page/2 Post: /blog/%category%/%postname%/ Tags: /blog/%tag%/ and /blog/%tag%/page/2 My problem is that I am unable to have both my permalink 'custom structure' and 'category/tag base' with the "blog" prefix, without having page or pagination 404 errors. I am working on a dev site which has no plugins and a custom theme which is not ineterferring. I would like a plugin-free solution which is …
Category: Web

Custom rewrite rule, url returning 404

I have a custom URL like this: website.com/show/?id=9999&n=page-name and I'm trying to come up with a mod_rewrite rule to convert to website.com/show/9999/page-name/ /show/ is a page name. Here's the rules I'm using in .htaccess: <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteBase / RewriteRule ^show/(.*)$ /show/?id=$1 [R=301,NC,QSA] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> This is working, it rewrites website.com/show/?id=9999` to website.com/show/9999/ Then I modified the rule for the second query string: RewriteRule …
Category: Web

removed index.php now all pages 404

I added this code to my .htaccess file to get rid of index.php, but now all the pages 404 (the hyperlinks are mapped to the correct url) # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress i set up my permalinks using http://1.1.1.1/%postname%/ what are the next steps in order to troubleshoot this issue? what is the default permalink for me to …
Category: Web

Wordpress multisite subdirectory redirect infinite loop issue

Any time I create a new site on my multisite install, I get an infinite loop redirect when navigating to that site's admin. I'm using the default htaccess supplied by WP for my subdirectory install. Here's what I have: RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) site/$2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ site/$2 [L] RewriteRule . index.php …
Category: Web

How can I remove multiple slashes?

Basically that, I have domain.com/ but if I visit domain.com// or with more slashes I would like to remove the extra ones and just leave one of them. I found this but it's not working, I added on the .htaccess file. <IfModule mod_rewrite.c> RewriteBase / RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$ RewriteRule (.*) %1/%2 [R=301,L] </IfModule> Keep in mind I used the homepage as an example, but it can happen on any page, adding extra slashes doesn't break the page but I need …
Category: Web

Basic Auth .htaccess on wp-login, but allow logout from woocommerce

I use a .htaccess basic auth on my WC site to help prevent hackers accessing wp-login, which works well... except with WooCommerce if a logged in customer wants to logout from their account - upon clicking the logout link - they are greeted by the Basic Auth popup asking them to "authorise" (generated by our .htaccess). On Woocommerce dashboard: Hello MrTest (not MrTest ? Log out) << clicking on "Log out" brings up the Basic Auth login box.... how can …
Category: Web

Duplicate WordPress site to subdirectory but use same db?

I have tried to just copy the whole root folder into a subdirectory. I understand the .htaccess file has to be changed. But can't get it to work right. Is it something more than changing the htaccess file I'll have to do to make this possible? As I said in the question, I want to use the same database. So I can't change any URL's in the database. Edit: I have figured out that the site actually is going in …
Category: Web

Redirect all posts permalinks from ".html" to "/"

How can I redirect all posts permalinks from .html to / in WordPress? To be more clear, for example, a post URL like this: http://example.com/%category%/%postname%.html To be redirected to: http://example.com/news/%postname%/.html It's simple to redirect them one by one, but I need a rule to redirect all posts. My current .htaccess setup is: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
Category: Web

Getting a 500 internal server error ONLY on wp-admin/options-permalink.php

I have access to the admin panel, and everything works fine. I can click settings->reading and change anything I want to. But if I click settings->permalinks I get a 500 internal server error. Here's what I've tried: I deleted the .htaccess file - nothing changed. I edited the .htaccess (because I am migrating this site to a new domain) and now I have all the page links working on the front end AND all the admin links EXCEPT permalinks. In …
Category: Web

Why wordpress multisite redirect to wp-signup if site exists?

I just create a site on my Multisite domain (example.com), for instance site1.example.com After this, I try to enter on https://site1.example.com/wp-admin, but I'm redirected to https://www.example.com/wp-signup.php?new=example.com My .htaccess containt this lines: RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteRule . index.php [L] I have installed, among others, this plugins …
Category: Web

Pagination redirect set in .htaccess file is not working

I'm trying to redirect like below but it's not working. http://example.com/page/2 -> http://example.com/item/page/2 Below is the source of .htaccess file: RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.hogehoge\.com RewriteRule (.*) http://hogehoge.com/$1 [R=301,L] RewriteRule ^hogehoge.com/page/(.*)$ http://hogehoge.com/item/page/$1 [R=301,L] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
Category: Web

subdirectory index.php is not working

I have setup wordpress in the root directory and at the same level I have some other directories e.g named "sq". Under sq there are subdirectories like first, second, ... under each subdirectory there is index.php file. Problem is when I am accessing http://example.com/sq/first it is giving me 404 page of root wordpress. I tried index.html instead of index.php and that is working. So index.php is not woking and I need php not html. I have tried all the possible …
Category: Web

Site redirects to wrong url when saving settings

I have a subdomain: https://blog.example.com/ I forcibly redirects to subdirectory: https://www.example.com/blog By changing site URL and some RewriteRule on .htaccess. Now the website and admin works fine except a small issue like when I tried to click save button on settings page (eg: Setting > Writing ) the site redirects to main domain: https://www.example.com/wp-admin/options-writing.php?settings-updated=true /blog is missing in the URL and end up in to main website 404 page. My .htaccess file looks like : # BEGIN WordPress <IfModule mod_rewrite.c> …
Category: Web

Old blog/ and blog/feed/ URLs not working after moving blog to top-level via .htaccess

For a long time I served my blog from http://www.murrayc.com/blog/, with the wordpress installation in /home/murrayc/murrayc.com/blog/. Now I've moved it to http://www.murrayc.com/, without moving the wordpress installation on the filesystem. I did that by: Changing the "Site Address (URL)", in Settings->General, to http://www.murrayc.com. I kept the "WordPress Address (URL)" as http://www.murrayc.com/blog Adding a RedirectRule in my top-level .htaccess at /home/murrayc/murrayc.com/, so that, for instance, permalink/something could be used instead of blog/permalink/something. The older blog/permalinks still seem to work too. However, …
Category: Web

Multisite Redirection to new domains

I have a multisite website with 5 domains in WordPress which uses WordPress MU Domain Mapping plugin. I want to redirect every subpage to new domain, but we will be still using the homepage, because it contains some links inside of it, so root, wp-admin and wp-login, should be still accessible and not redirected. How to set this up in .htaccess so WordPress will still function? example of a domain: oldone.com/ --> no redirection oldone.com/wp-admin --> no redirection oldone.com/wp-login --> …
Category: Web

Multisite Subdomains result in 403 Forbidden

So I have setup multisite as per the WordPress website page: https://codex.wordpress.org/Create_A_Network I'm using the latest WordPress 4.8. Setup example.com sub.example.com All requests for the subdomain for the dashboard and the site give a 403 - forbidden You don't have permission to access / on this server. .htaccess RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin RewriteRule ^wp-admin$ wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^(wp-(content|admin|includes).*) …
Category: Web

Change wp-login.php? Problem with .htaccess password protection and multi user shop

I use a .htaccess password protection to secure my wp-login.php. For me as the admin of the WP/WooCommerce installation everything works fine so far (my password manager helps me to remember the tons of passwords). But now I have the problem, that there are are also registered customers which should be able to see their own customer accounts. When these customers want to log out from their account, they click on the link /customer-logout/ (which is in fact just the …
Category: Web

Htaccess file reset automatically how to fix this issue

Often my WordPress htaccess file was reset am not able to find the root cause of this issue. But I guess this may happen when installing any plugin or manually take a complete backup of the site. Also, I have checked htaccess file permission as well. Please let me know how to fix this issue soon. Thanks in advance.
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.