How to redirect postname htaccess - .htaccess

how to setup .htaccess: redirect/ /%postname% to /%blog%/%postname%
My current permalink structure is: %postname%
I'd like it to be: /%blog%/%postname%

Related

How redirect comma separated url with htaccess?

There are 2 different URLs https://maldivesresorts.com.au/package/vakarufalhi-island-resort-all-meals-drinks/ and https://maldivesresorts.com.au/package/vakarufalhi-island-resort-all-meals-drinks/ but while SEO audit I found the wrong url and it is showing like https://maldivesresorts.com.au/luxury-resorts-study-vakarufalhi-maldives-resort/,https://maldivesresorts.com.au/package/vakarufalhi-island-resort-all-meals-drinks/,here so I want to redirect the wrong url to another page.
So it should be redirect
to /hot-deals.
Here is my htaccess code but it doesn't seems working
RewriteEngine On
redirect /luxury-resorts-study-vakarufalhi-maldives-resort/,https://maldivesresorts.com.au/package/vakarufalhi-island-resort-all-meals-drinks/,here /hot-deals
This is how redirects work:
ref: https://www.semrush.com/blog/htaccess-redirect/
So you should be doing:
RewriteEngine On
redirect 301 /luxury-resorts-study-vakarufalhi-maldives-resort/ /hot-deals
redirect 301 /package/vakarufalhi-island-resort-all-meals-drinks/ /hot-deals
However, you look like you're redirecting folders rather than files so you should simply look at this question which your question appears to be a duplicate of.

.htaccess redirect all old URL to new subfolder URL

We have a multilingual website with three languages: Flemish, Dutch and French. The main language doesn't have a subfolder, the rest does. So it look something like this:
Flemish: website.com/...
Dutch: website.com/nl/...
French: website.com/fr/...
We would like to give the main language (Flemish) a subfolder as well. The URL structure will look like this: http://website.com/be/...
I was wondering if there was an easy way - using the htaccess file - to 301 redirect all the old Flemish URLs (website.com/...) to the new version (website.com/be/...)? URL rewriting is probably faster than redirecting each URL invidually.
Do something like this to redirect URL
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^website.com.*$ http://website.com/be/ [R=301,L]

How can I set the RewriteModule in .htaccess?

I will present a to the point example.
I have a domain name as: www.abc.com
And another domain name as: www.123.com
Now i want to write a rewritemodule in .htaccess for the following case:
If i request a url like: www.123.com/xyz
It will redirect my request to www.abc.com/track/index.php?ext=xyz
Also please tell me on which directory i should keep that .htaccess file.
Thanks.
In the root folder of www.123.com, you would create an htaccess file with the following line:
RedirectMatch 301 (.*) www.abc.com/track/index.php?ext=$1
Since you are doing an external redirect, it is not necessary to use mod_rewrite.

how to write .htaccess

I have tried but have not found proper solution for PHP .htaccess
Folder and files information:
.htaccess (on root)
/profile/personal.php
/profile/exam/exam_information.php
Sending URLs from (personal.php) and (exam_information.php)
/profile/2012/A1PPOAQU7
........\-------------/ // Friendly URL
/profile/exam/2012/A1PPOAQU7
.............\-------------/ // Friendly URL
I found, htaccess but it works for single URL only. Please check what is wrong in the code.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+)$ /profile/personal.php?pid=$1
RewriteRule ^([a-zA-Z0-9-/]+)/$ /profile/personal.php?pid=$1

htaccess to redirect url with params

I have to redirect a url to another url with all its parameters using htaccess.
My incoming url will be something like this:
www.mydomain.com/book-it.jsp?id=3&var1=values&var2=value2...
and I want to get it in PHP (book-it.php) as something like this (with all its parameters):
www.mydomain.com/book-it.php?id=3&var1=values&var2=value2...
I was using JSP and from now on moving to PHP and we need to use same URL since this url is already published with my application and I can't change that now. I need to get that url and parameters to another file.
You have 2 main approaches:
1) Using Redirect directive:
Redirect 301 /book-it.jsp http://www.mydomain.com/book-it.php
2) Using mod_rewrite module (this needs to be placed in .htaccess in website root folder. If placed in Apache config file (inside <VirtualHost>, for example) the rules need to be modified slightly):
RewriteEngine On
RewriteBase /
RewriteRule ^book-it\.jsp$ http://www.mydomain.com/book-it.php [QSA,NC,R=301,L]
Both of them will preserve query string.

Resources