htaccess is not resolving correctly

Avatar
  • Answered
I have installed OJS in a subfolder.Its called "journals".I need to remove this /journals from url.I am having below .htaccess in my root folder(/).Its working fine in my localhost(XAMPP).But not working here in inmotion.Please have a look.


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

---------

* Are you getting any error messages?
* When did the issue begin occurring and how can we replicate it?
* What software are you using to build your site?

1.no.but seeing some 406.shtml
[Sat Oct 13 16:26:59 2012] [error] [client 1.23.216.161] File does not exist: /home/bmsnfc5/public_html/406.shtml, referer: http://www.bmsnf.com/journals/index.php/tcr

2.after putting htaccess in root folder.
just go to www.bmsnf.com/journals/index.php/tcr.
this htaccess should make it
www.bmsnf.com/index.php/tcr. but its not happening.
Avatar
JacobIMH
Hello Sunder, and thanks for the question.

It looks like your requests were triggering a (mod_security) rule:

[Mon Oct 15 08:49:46 2012] [error] [client 174.77.92.170] ModSecurity: Access denied with code 406 (phase 2). Pattern match "(?:\\\\b(?:(?:type\\\\b\\\\W*?\\\\b(?:text\\\\b\\\\W*?\\\\b(?:j(?:ava)?|ecma|vb)|application\\\\b\\\\W*?\\\\bx-(?:java|vb))script|c(?:opyparentfolder|reatetextrange)|get(?:special|parent)folder|iframe\\\\b.{0,100}?\\\\bsrc)\\\\b|on(?:(?:mo(?:use(?:o(?:ver|ut)|down|move|up)|ve)| ..." at REQUEST_FILENAME. [file "/usr/local/apache/conf/modsec2.user.conf"] [line "121"] [id "950004"] [msg "Cross-site Scripting (XSS) Attack"] [data ".cookie"] [severity "CRITICAL"] [tag "WEB_ATTACK/XSS"] [hostname "bmsnf.com"] [uri "/journals/lib/pkp/js/jquery.cookie.js"] [unique_id "UHwGaq3NfJcAAFfkr74AAAIL"]

I've gone ahead and disabled the rule [950004] that this was triggering so now it should be pulling up for you without a 406 error.

However taking a look at you Rewrite rules I don't think it's going to do what you seem to be explaining it to do.

You currently have it setup so that if someone types in:

http://bmsnf.com/index.php/tcr

The actual request is written to:

http://bmsnf.com/journals/index.php/tcr

Is this the end goal you were trying to accomplish? Or were you attempting to get rid of [/journals] when it is typed in? Because currently you don't have a (index.php) script in just your main [/public_html] directory, so if you're trying to rewrite requests there from the [/journals] directory you're going to run into problems.

Please let us know exactly what you're trying to accomplish as (.htaccess) rewrites might not be the best option to use.

- Jacob