OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



could not get mod_rewrite to work

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

could not get mod_rewrite to work

Postby newbies » Sat Feb 23, 2013 9:32 pm

I tried to find a solution in this forum in vain. There are posts but they are posted years ago.

I installed 2.4.1 under the root directory as /home/mydomain/www/ojs

my config url settings are as follows:
Code: Select all
base_url = "http://www.mydomain.org/ojs
base_url[index]= http://mydomain.org
base_url[journal] = http://www.mydomain.org/journal


my .htaccess file in root directory is this:
Code: Select all
#Options +FollowSymLinks
RewriteEngine On
RewriteBase /

# Use this set of 3 lines for each of your journals
RewriteCond %{SERVER_NAME} ^www.mydomain.org
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/journal/$1 [L]

# Use this set of 3 lines to allow access to the site level
RewriteCond %{SERVER_NAME} ^www.mydomain.org
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/index/$1 [L]


The URL setting in configure file seem to work, because I can see various links on the journal page has changed to expected format, for example, the link for journal ABOUT is http://www.mydomain.org/journal/about. The problem is when links are clicked, I received 500 error.

Could someone take a look at my code to see where the problem is? Thank you very much!
newbies
 
Posts: 84
Joined: Sat Feb 23, 2013 9:15 pm

Re: could not get mod_rewrite to work

Postby newbies » Tue Feb 26, 2013 1:24 am

I still need help, please!!

I check my Apache error log and found this for the 500 error:
Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary
newbies
 
Posts: 84
Joined: Sat Feb 23, 2013 9:15 pm

Re: could not get mod_rewrite to work

Postby asmecher » Tue Feb 26, 2013 9:36 am

Hi newbies,

This is an Apache configuration issue, not an OJS issue; I'd suggest trying stackoverflow.com or reading through these forums for more posts on the rewrite subject. Unfortunately we can't help with debugging mod_rewrite rulesets.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8674
Joined: Wed Aug 10, 2005 12:56 pm

Re: could not get mod_rewrite to work

Postby Garant » Wed Jun 05, 2013 11:14 am

Hello!
I don't know to which topic to write so I will post my question here.
In Site administrator's area -> Hosted Journals we can configure path to each journal.
But this path is common for multilanguage journals. From SEO side the best approach is to have different journal's name in different languages (it will affect actual journal's URL).
So this is impossible to configure through OJS system.
But is there a way to make it with mod_rewrite or .htaccess?
Maybe it was already discussed?
Thank you!
Garant
 
Posts: 217
Joined: Wed May 30, 2012 8:53 am

Re: could not get mod_rewrite to work

Postby Garant » Fri Jun 07, 2013 10:26 am

Hi!
I've very low experience with mod_rewrite. Searching through forums I've found this example:

The main path to one of the journals is:
https://www3.domain.net/ojs/intellectual-economics/
Once the locale has been changed I'd like to change to URL address to corresponding translation.
For example Lt locale should look like this:
https://www3.domain.net/ojs/intelektine-ekonomika/
But this rule doesn't work...
Code: Select all
RewriteCond %{HTTP_COOKIE} ^.*user/setLocale=lt_LT.*$ [NC]
RewriteRule /?ojs/intellectual-economics ojs/intelektine-ekonomika [QSA,L]

Am I doing something wrong or first line doesn't accept the param?
Maybe, someone who is more experienced could help me with this?
Garant
 
Posts: 217
Joined: Wed May 30, 2012 8:53 am

Re: could not get mod_rewrite to work

Postby newbies » Wed Aug 14, 2013 8:01 pm

asmecher wrote:This is an Apache configuration issue, not an OJS issue; I'd suggest trying stackoverflow.com or reading through these forums for more posts on the rewrite subject. Unfortunately we can't help with debugging mod_rewrite rulesets.


Thank you, but I still could not resolve the issue after reading many posts on stackoverflow and many trials. I own a dedicated server (CentOS + Cpanel) which hosts several of my sites, many of which run php programs such as forums and job boards with URL redirects without any problem. I just don't know why mod_rewrite becomes problematic for ojs. Could you be more specific about what particular setting to look at?
newbies
 
Posts: 84
Joined: Sat Feb 23, 2013 9:15 pm

Re: could not get mod_rewrite to work

Postby asmecher » Thu Aug 15, 2013 8:55 am

Hi newbies,

If you want to change the locale depending on the URL, you might want to try applying the patches for bug #8353, which is scheduled for release in OJS 2.4.3. It allows easier control over the locale via the URL.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8674
Joined: Wed Aug 10, 2005 12:56 pm

Re: could not get mod_rewrite to work

Postby Garant » Thu Aug 15, 2013 10:06 am

Hi, Alec!
So after the patch this line should be modified in that way?
Code: Select all
RewriteCond %{HTTP_COOKIE} ^.*user/uiLocale=lt_LT.*$ [NC]

Thank you!
Garant
 
Posts: 217
Joined: Wed May 30, 2012 8:53 am

Re: could not get mod_rewrite to work

Postby asmecher » Thu Aug 15, 2013 10:13 am

Hi Garant,

I can't help with specific mod_rewrite rules -- but rather than trying to use a cookie to set the locale, you should be able to alter the URL that OJS receives to include a "uiLocale" URL parameter, i.e.: http://www.myjournal.com/index.php/myJournal/issue/current?uiLocale=en_US

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8674
Joined: Wed Aug 10, 2005 12:56 pm

Re: could not get mod_rewrite to work

Postby Garant » Thu Aug 15, 2013 10:31 am

Understood.
This part should be done modifying core files or via .htaccess rules?
Thank you!
asmecher wrote:Hi Garant,

I can't help with specific mod_rewrite rules -- but rather than trying to use a cookie to set the locale, you should be able to alter the URL that OJS receives to include a "uiLocale" URL parameter, i.e.: http://www.myjournal.com/index.php/myJournal/issue/current?uiLocale=en_US

Regards,
Alec Smecher
Public Knowledge Project Team
Garant
 
Posts: 217
Joined: Wed May 30, 2012 8:53 am

Re: could not get mod_rewrite to work

Postby asmecher » Thu Aug 15, 2013 10:35 am

Hi Garant,

I'm not sure I understand the question. Are you asking where to put mod_rewrite rules? Or do you mean some kind of modification to the OJS code?

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8674
Joined: Wed Aug 10, 2005 12:56 pm

Re: could not get mod_rewrite to work

Postby Garant » Thu Aug 15, 2013 10:40 am

No :)
I'm asking how I can achieve the URL to look like: http://www.myjournal.com/index.php/myJournal/issue/current?uiLocale=en_US
I.e. how the new additional param to URL/URL's could be added?

asmecher wrote:Hi Garant,

I'm not sure I understand the question. Are you asking where to put mod_rewrite rules? Or do you mean some kind of modification to the OJS code?

Regards,
Alec Smecher
Public Knowledge Project Team
Garant
 
Posts: 217
Joined: Wed May 30, 2012 8:53 am

Re: could not get mod_rewrite to work

Postby asmecher » Thu Aug 15, 2013 10:46 am

Hi Garant,

OJS itself won't include the uiLocale parameter in its URLs; it's intended for use e.g. with mod_rewrite.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8674
Joined: Wed Aug 10, 2005 12:56 pm

Re: could not get mod_rewrite to work

Postby Garant » Thu Aug 15, 2013 10:50 am

Understood, will try to implement :)
Thank you!
asmecher wrote:Hi Garant,

OJS itself won't include the uiLocale parameter in its URLs; it's intended for use e.g. with mod_rewrite.

Regards,
Alec Smecher
Public Knowledge Project Team
Garant
 
Posts: 217
Joined: Wed May 30, 2012 8:53 am

Re: could not get mod_rewrite to work

Postby newbies » Sat Aug 24, 2013 9:52 pm

I manged to get the mod_rewrite to work by using the following lines in .htaccess

Code: Select all
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on

# RewriteCond %{SERVER_NAME} ^www.domain.org
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^journal(.*)$ "http\:\/\/www.domain.org\/index.php\/journal$1" [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ "http\:\/\/www.domain.org\/index.php\/index\/$1" [QSA,L]
</IfModule>


But there are two problems:

first, although all URLs shown when mouse over look like the following one:
http://www.domain.org/journal/about

but, when the page is loaded, the url in the address bar still looks like the one below with "index.php" still in the URL:
http://www.domain.org/index.php/journal/about

second, the only url which does not work is the following one. Browser shows "The page isn't redirecting properly".
http://www.domain.org/journal/login

Is the first problem just by design, not a problem? For the 2nd problem, I have to mention that I turned on ssl login.
newbies
 
Posts: 84
Joined: Sat Feb 23, 2013 9:15 pm

Next

Return to OJS Technical Support

Who is online

Users browsing this forum: No registered users and 4 guests