How to forward all requests starting with a specific folder name to the same folder

Question

In my WordPress website main directory, I created a folder servers, which contains two files .htaccess & index.php.

In the .htaccess file, I add those lines to redirect all requests to that folder to the index.php file.

# Enable rewriting.
RewriteEngine on

# Optional: do not allow perusal of directories.
Options -Indexes

# Optional: explicitly enable per-directory rewrites in the .htaccess context.
Options +FollowSymLinks

# Required when not in the webroot. Always use a trailing slash.
RewriteBase /

# To be able to access existing directories and files (standalone scripts).
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

# Redirect everything else to index.php.
# Add QSA to ensure that querystring variables are registered as such.
RewriteRule . index.php [L,QSA]

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

So whenever a user requests a link like example.com, example.com/foo or example.com/foo/bar, the default WordPress website should load. and when I request any url that starts with the servers folder: example.com/servers, example.com/servers/foo, example.com/servers/foo/bar, I want the example/com/servers/index.php file to be executed.

The current example.com/servers/.htaccess file only executes this url example.com/servers with the example.com/servers/index.php file but it’s not executing other urls that start with the servers folder(example.com/servers/foo, example.com/servers/foo/bar) by the example.com/servers/index.php file.

How can edit the htaccess file so that all request to example.com/servers/* are executed by the example.com/servers/index.php file

0
, Yazan W Yusuf 3 years 2020-07-11T07:10:38-05:00 0 Answers 39 views 0

Leave an answer

Browse
Browse