Mod-rewrite remove folder name from url

I use OJS and I installed it in a folder called "logs". I created several magazines there (for example, "journal1", "journal2", etc.).

Now I get the paths as follows: www.example.com/journals/index.php/journal1 , www.example.com/journals/index.php/journal2 , etc.

I want to display www.example.com/journals/index.php/journal1 looks like www.example.com/index.php/journal1 (removing part of the journal from the URL).

I cannot move OJS to root because there are other files there.

Here is the .htaccess file that I am currently using (it is located in the logs folder and gives me 500)

 <IfModule mod_rewrite.c> RewriteEngine on RewriteCond $1 !^journals RewriteRule ^(.*) /journals/$1 [L] </IfModule> 

Also here is error.log

 [Fri Oct 12 22:16:45 2012] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. 
+6
source share
1 answer

When you put these rules in the htaccess file in the /journals directory, this causes a rewrite loop. $1 never starts with logs because you are in the log directory, so the rule continues to apply.

You need to put something like this in your htaccess file in your root site directory / :

 RewriteEngine On RewriteCond %{REQUEST_URI} !^/journals RewriteRule ^index\.php(.*)$ /journals/index.php$1 [L] 
+3
source

Source: https://habr.com/ru/post/927586/


All Articles