Hide wordpress in site url - .htaccess

My site (grosvenorauctions.com) uses a modified Wordpress install to create a custom look - the blog part is driven by WP but other parts are outside WP. Consequently the index page for my site is not in the root folder but actually within the Wordpress folder. I am using htaccess (RedirectMatch ^/$ http://www.grosvenorauctions.com/wordpress/) to point to the index page in Wordpress but additionally I would like to hide the /wordpress/ part of the url. Is this possible? To be clear the htaccess file I have modified is in the root, not WP's own htaccess file.
Thanks

RewriteEngine On
RewriteBase /
RewriteRule ^/$ /wordpress/ [L]

Related

htaccess RewriteRule to existing folder in Wordpress environment

I need to "internally rewrite" (without any visual redirection) all URLs from an existing folder (and everything inside of it) to its index.php file, similar as what Wordpress does, the problem is, no matter what I try it, either Wordpress overrides it showing their 404 Error page, or the site breaks.
For example, rewrite all of this URLs:
https://www.example.com/folder
https://www.example.com/folder/
https://www.example.com/folder/text
https://www.example.com/folder/text/
https://www.example.com/folder/some/text
https://www.example.com/folder/some/text/
https://www.example.com/folder/some/more/text/......
Basically anything inside /folder/ or any subfolder (whether exist or not) should be internally rewrite to https://www.example.com/folder/index.php and keeping the actual Wordpress working as usual.
I've tried some examples from other sites, as well as from similar questions like:
How does RewriteBase work in .htaccess
Redirect all to index.php using htaccess
.htaccess mod_rewrite - how to exclude directory from rewrite rule
The last one, is because I thought I could exclude the whole /folder/ path from Wordpress rewrites and create an .htaccess file inside that folder to manage it that way, well, Wordpress still shows its 404 error page.
Note: "folder" is a real folder inside the root domain, so is the main .htaccess file, and the Wordpress itself. This folder contains an index.php file.
This is the original Wordpress .htaccess file as shown here:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
I hope someone can help me out, thank you.

.htaccess sitemap rewrite/redirect

I have a single domain, multi store setup on magento 2.3
For example
example.com/jp/
example.com/uk/
however the sitemaps get generated to their store folders within a sitemaps folder in the root dir, such
example.com/sitemaps/jp/sitemap.xml
My google webmaster domains are setup as such
example.com/jp/
So when I need to submit a sitemap it needs to be example.com/jp/sitemap.xml
I've used
#Sitemap: Japan http://www.example.com/sitemaps/jp/sitemap.xml
RewriteCond %{HTTP_HOST} ^.*example\.com$
RewriteRule ^sitemap.xml$ sitemaps/jp/sitemap.xml [NC,L,R=301]
When I access example.com/jp/sitemap.xml its a 404
I'd like example.com/jp/sitemap.xml to redirect to example.com/sitemaps/jp/sitemap.xml
Is there a way of doing this through .htaccess?
You can use this rule as topmost rule in site root .htaccess:
RewriteEngine On
RewriteRule ^[a-z]{2}/sitemap\.xml$ /sitemaps/$0 [L,NC,R=301]
Make sure there is no other .htaccess and this rule is top most rule.

htaccess redirect from folder with subdirectory to single path directoy

Previously my site was in wordpress, now converted into html.
I have 500+ pdfs that needs to redirect from
mysite.com/wp-content/themes/my-theme/pdfs folder to mysite.com/pdf/
Do you have server-level access to the site? If so I would create a symbolic link in the public root directory of your website to wp-content/themes/my-theme/pdfs and call it pdf.
If all you can do is .htaccess, then you can create a file like this:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^pdf/(.*)$ /wp-content/themes/my-theme/pdfs /$1 [R=301,NC,L]
You might check out a great tutorial on rewrite rules.
I tried like this it works for me.
RewriteRule ^wp-content/themes/my-theme/pdfs/(.*)$ /pdf/$1 [R=301,NC,L]

htaccess conditions to redirect variants of directory URL

I've dug around without much luck finding a solution.
I have a WordPress MultiSite using sub-directories as "temp" URLs so clients can review prior to mapping their domain name.
The login for the mapped domains is domain.com/ui which works with a redirect in my htaccess.
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^ui$ /wp-login.php? [R=301,NE,NC,L]
I've also tried this RewriteRule ^ui(.*)$ /wp-login.php [L,R=301]
However, when attempting to login to a temp URL as described above it does not redirect.
I would like a solution that disregards sub-directories and for that matter any permalink structure and redirects /ui to /wp-login.php
Here are a few examples.
http://adopttheweb.com/ui
http://iemajen.com/emajenwebservices/ui
These are both on the same MultiSite blog. The first has been mapped to a domain whereas the second has not and is simply running at a "sub-directory" of the root / parent site.
Put the following code at main directory .htaccess file
RewriteEngine On
RewriteRule ^ui(.*)$ /wp-login.php [L,R=301]
You can also do it by PHP by putting header('Location: path/to/target.php'); at the ui directory index page etc

htaccess 301 redirect with wildcard to a single page

We took over a website with about a kabillion pages in the old site root directory done in htm that need to be retired. I want to do a 301 redirect from the pages to the index.php in the root directory of the new site using a wildcard. An example of the page naming structure follows:
oldpage_dees.htm
oldPage_dat.htm
oldPage_deeudderting.htm
and so on. As stated, I need them redirected to the index.php in the root directory. Going by examples and discussions here I've tried:
RewriteEngine On
RewriteRule ^/oldpage_([\w]*).htm$ /index.php [R=301,L]
but I get a 404 error.
Any suggestions? Thanks in advance!
As .htaccess is directory level configuration file, you don't need to specify forward slash, I think this will do the job:
RewriteEngine On
RewriteRule ^oldpage_([\w]*).htm$ index.php [R=301,L]
Meanwhile, you can use the following .htaccess tester to debug your rewrite rules.

Resources