How to redirect subdirectory to url parameter in .htaccess?

Member

by domenico , in category: Third Party Scripts , 10 days ago

How to redirect subdirectory to url parameter in .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by darion , 9 days ago

@domenico 

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

1
2
RewriteEngine On
RewriteRule ^subdirectory/(.*)$ /index.php?url=$1 [L,QSA]


This will redirect any request to the "subdirectory" to index.php file passing the subdirectory path as a URL parameter "url".


Make sure to replace "subdirectory" with the actual name of your subdirectory and adjust the destination URL according to your needs. Also, ensure that mod_rewrite is enabled on your server for this code to work.