Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod-rewrite remove folder name from url

I am using OJS and I have installed it inside a folder called "journals". I have created some journals there (for example "journal1", "journal2", etc).

Now I am getting paths like this: www.example.com/journals/index.php/journal1, www.example.com/journals/index.php/journal2, etc.

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

I can't move OJS to root because I have some other files there.

Here is the .htaccess file which I am using currently (it's in "journals" folder and giving me a 500)

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

Also Here is the 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. 
like image 844
MBanerjee Avatar asked Oct 12 '12 15:10

MBanerjee


1 Answers

When you put those rules inside the htaccess file in your /journals directory, it's causing a rewrite loop. $1 never starts with journals because you're inside the journals directory, thus the rule keeps getting applied.

You'll need to put something like this in your htaccess file in your site-root, the / directory:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/journals
RewriteRule ^index\.php(.*)$ /journals/index.php$1 [L]
like image 84
Jon Lin Avatar answered Nov 02 '22 21:11

Jon Lin