How to redirect a parameter to a subfolder with .htaccess?

Member

by mac , in category: Third Party Scripts , 3 months ago

How to redirect a parameter to a subfolder with .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by mallory_cormier , 3 months ago

@mac 

To redirect a parameter to a subfolder using .htaccess, you can use the following code:

1
2
3
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/your-parameter-here$
RewriteRule ^(.*)$ /subfolder-name/$1 [L]


Replace "your-parameter-here" with the actual parameter you want to redirect and "subfolder-name" with the name of the subfolder you want to redirect it to.


This code checks if the requested URI matches the specified parameter and then redirects it to the specified subfolder. The [L] flag tells Apache to stop processing any further rewrite rules if this rule is matched.

Related Threads:

How to redirect a parameter to a subfolder with .htaccess?
How to redirect subdirectory to url parameter in .htaccess?
How to redirect subfolder/index.php to subfolder/?
How to remove get parameter from url with .htaccess?
How to add a parameter to a url using .htaccess without breaking in wordpress?
How to remove specific query_string parameter in .htaccess?