url rewriting – Redirect htaccess

I need to help with redirect my page.

For example I have websites https://example.com. I need to move content from https://example.com to https://example.com/blog. That is not problem and I do that with a change home_page URL. That work pretty well. But Now I need to add redirect from old https://example.com to https://xmpl.com.
I want to do with .htaccess but that does not work. Can you help me guys?

Here are some of my attempts of this but both does not work.

RewriteEngine On
RewriteRule https://example.com/ https://xmpl.com/ [L,R=302]

or

RewriteEngine On
Redirect 302 https://example.com/ https://xmpl.com/

Thank you for your help and time guys.

magento2 – URL rewrite having query string via htaccess in magento 2

I have current URL like this:

http://localhost/projectname/industries/index/index/industry/aircraft

(Here industries is the frontend route, index is controller and second index is action
industry is query param name, and aircraft is param value)

I want after rewrite the url will be :

http://localhost/projectname/industries/industry/aircraft

Or

http://localhost/projectname/industries/aircraft

How to replace ‘?’ and `=` with slashes in a URL using .htaccess?


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




htaccess – How to replace ‘?’ with ‘/’ in an url parameter?


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




Is there an order to placing commands in .htaccess file?

I have to keep the below block at the bottom of my htaccess file or other commands won't work. Why? I didn't think there was any order to commands in the Apache file. Is that right?
# BEGIN WordPress
#NEEDS TO BE AT END OF FILE OR HIDE DEBUG FILE CODE DOESN'T WORK
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ – (L)

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 (L)

RewriteCond %{REQUEST_FILENAME} -f (OR)
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^…

Is there an order to placing commands in .htaccess file?

.htaccess not working – on add on domain

The original domain files are under /home/account/public_html, the add-on domain is /home/account/add-on-domain.

Both sites have a .htaccess file, all the same apart from the domain names, both are in main directory.

Main domain:

Options +SymLinksIfOwnerMatch -FollowSymLinks -Indexes RewriteEngine on RewriteCond %{HTTP_HOST} ^domain1.com (NC) RewriteRule ^(.*)$ http://www.domain1.com/$1 (L,R=301)

add on domain:

Options +SymLinksIfOwnerMatch -FollowSymLinks -Indexes RewriteEngine on RewriteCond %{HTTP_HOST} ^domain2.co.uk (NC) RewriteRule ^(.*)$ http://www.domain2.co.uk/$1 (L,R=301)

There is more in the .htaccess, the add-on doesn’t read it at all.

adding Allowoverrides All on main domain crashes it, does nothing on add on domain.

Can I use .htaccess to make permalinks to sub-pages?

I have a bunch of pages that I’d like to be accessible with simple URLS without having to keep them in my webhost’s root folder.

I put these pages into a subfolder called my_pages

and put the following in my htaccess

Options +FollowSymLinks -MultiViews
Header set Cache-Control "max-age=0,no-store"

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^page1$ /page1/ (L,R)
RewriteRule ^page1/(.*)$ my_pages/page1/$1 (L,PT)

RewriteRule ^page2$ /page2/ (L,R)
RewriteRule ^page2/(.*)$ my_pages/page2/$1 (L,PT)

RewriteRule ^page3$ /page3/ (L,R)
RewriteRule ^page3/(.*)$ my_pages/page3/$1 (L,PT)

I never want users to see my_pages anywhere.
It mostly works, but

  1. I dislike that I have to add them one by one. I wasn’t able to solve this with regex without getting redirect loops or other worries..

  2. for some subpages, it will ultimately redirect to a url taht includes my_pages which I do not want users to see. For example if I go to example.com/page1/subpage without a trailing / it takes me to example.com/pages/page1/subpage

htaccess – Azure WordPress deny xmlrpc

I am trying to disable xmlrpc.php by using plugin and also by using .htaccess. But didn’t seem to be working, when i hit mysite.com/xmlrpc.php i still get a “XML-RPC server accepts POST requests only.”
Trying these on .htaccess file:

<Files xmlrpc.php>
order deny,allow
deny from all
allow from xxx.xxx.xxx.xxx
</Files>```

```# BEGIN DS-XML-RPC-API
# The directives (lines) between "BEGIN DS-XML-RPC-API" and "END DS-XML-RPC-API" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.

# END DS-XML-RPC-API```

Htaccess redirect rule adds an unwanted variable

I’m trying to redirect logged-in users that land on a page to another page, but the redirect keeps adding the logged-in user’s name to the path / URL.

Say I’m logged in as Mario. The redirect includes that username into the redirected path, throwing up a 404 error.

Below is the content of the .htaccess file (without the redirect):

Options +FollowSymLinks
RewriteEngine On
AddEncoding gzip .gz
AddEncoding gzip .gzip
<FilesMatch ".(js.gz|js.gzip)$">
  ForceType text/javascript
</FilesMatch>
<FilesMatch ".(css.gz|css.gzip)$">
  ForceType text/css
</FilesMatch>

RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} !/ow_updates/index.php
RewriteCond %{REQUEST_URI} !/ow_updates/
RewriteCond %{REQUEST_URI} !/ow_cron/run.php
RewriteCond %{REQUEST_URI} !/e500.php
RewriteCond %{REQUEST_URI} !/captcha.php
#RewriteCond %{REQUEST_URI} (/|.php|.html|.htm|.xml|.feed|robots.txt|.raw|/(^.)*)$  (NC)
RewriteCond %{REQUEST_FILENAME} (/|.php|.htm|.feed|robots.txt|sitemap.xml|.raw|/(^.)*)$  (NC)
RewriteRule (.*) index.php

This is my redirect:

Redirect /photo/useralbums /my-profile

The result is that the user ends up at: /my-profile/Mario

8 – Use patch for .htaccess only on remote site

Following this post I’m working on a way to patch my .htaccess file so my changes don’t get overwritten by a drupal update.

But my .htaccess files most of the times are in my .gitignore because the extra code I add to the .htaccess file is only needed on my remote site. On my local site I need the default .htaccess file. How can I solve this?