OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Form Validation erros after URL rewrite

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.

Form Validation erros after URL rewrite

Postby kavikgb » Thu May 24, 2012 2:24 pm

Hello,

I have OJS application with 2 journals. Application was working fine until before I changed my code for URL rewrite. Now whats happening is when ever I try to submit/save any forms like Edit Profile/pwd change etc..,I get all the validation error on that page like "First Name is required , last name, email etc...) even when I enter proper data before hitting SAVE. It seams the data getting lost between the page post. but no idea how its happening. Its little urgent, someone pls help.

Below are my code in Httpd.conf file & OJS config file for url rewrite.

<VirtualHost *:80>
ServerName xxx.edu
DocumentRoot "c:/Apache/htdocs"
<IfModule mod_rewrite.c>
RewriteEngine on

RewriteRule ^/ojs/journal1(.*)$ ojs/index.php/journal1$1 [R=301,QSA,L]

RewriteRule ^/ojs/journal2(.*)$ ojs/index.php/journal2$1 [R=301,QSA,L]

RewriteRule ^/ojs/admin(.*)$ ojs/index.php/index/admin/$1 [R=301,QSA,L]

RewriteRule ^/ojs/user(.*)$ ojs/index.php/index/user$1 [R=301,QSA,L]

RewriteRule ^/ojs/login(.*)$ ojs/index.php/index/login/$1 [R=301,QSA,L]


</IfModule>
</VirtualHost>


OJS config file:

base_url[index] = http://xxx.edu/ojs
base_url[journal1] = http://xxx.edu/ojs/journal1
base_url[journal2] = http://xxx.edu/ojs/journal2

restful_urls = on

The above code works fine with navigating inside application but not with data SAVE. Let me know if I need to do some setting change or changes in above code.


Thank you,
kavitha
kavikgb
 
Posts: 9
Joined: Thu May 24, 2012 1:50 pm

Re: Form Validation erros after URL rewrite

Postby JasonNugent » Thu May 24, 2012 2:45 pm

Hi kavitha,

I guess my first question is what did you change in your URL rewrite? It sounds like the new patterns are intercepting the form submission URLs and redirecting them to new URLs without passing along the form data. Normally, for those sorts of things you don't use the L flag on a rewrite to a 301 redirect if you want to preserve POST data, you use 'P' and hand it off to the proxy module. However, this means that you'd need the proxy module also enabled within Apache.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 854
Joined: Tue Jan 10, 2006 6:20 am

Re: Form Validation erros after URL rewrite

Postby kavikgb » Thu May 24, 2012 4:53 pm

Hi Jason,

Thank you for your immediate reply. I wanted to give the two journals a separate URL like : www.xxx.edu/ojs/Journal1 which would implicitly redirect to www.xxx.edu/ojs/index.php/journal1. ie I tried removing index.php the whole. So if my understanding is correct do I need to replace "L" flag with "P" and remove the "R" completely or only the "301" and enable the proxy module within the httpd.conf file?

AS far as I read the posts in rewriting the URL, noticed that we rewrite the each Journal URL and Admin module. Whereas when I tried the same, things dint work when I go to "My Profile or Logout" from the side bar. It throws error that "this url does not exist", which made me add the rewrite to "USER & LOGIN" code too. does it sound ok to rewrite the USER & LOGIN module or am I making some mistake?

Can you please post me the code to enable the proxy code in Apache?. Since I am not at office now, I could now make changes & test ur suggestion. So will update you tomorrow morning.


Thank you,
Kavitha
kavikgb
 
Posts: 9
Joined: Thu May 24, 2012 1:50 pm

Re: Form Validation erros after URL rewrite

Postby JasonNugent » Fri May 25, 2012 3:38 am

Hi Kavitha,

There is a lot to getting mod_proxy up and running, to be honest, and the specific configuration would depend on your server and your journals. The full documentation for the module is available on Apache's website:

http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

And you may also want to use our search feature here on the forum to find similar posts related to using mod_proxy and mod_rewrite together.

Regards,
Jason
JasonNugent
Site Admin
 
Posts: 854
Joined: Tue Jan 10, 2006 6:20 am

Re: Form Validation erros after URL rewrite

Postby kavikgb » Tue May 29, 2012 11:28 am

Hello Jason,

I got things working fine. I replaced "L" flag with "P" in rewrite rule, immediately things started getting saved properly. Thank you for your suggestions. Below are my working code for others facing the same problem.

OJS congig.inc.php

base_url[index] = http://journal.xxx.edu
base_url[journal1] = http://journal.xxx.edu/journal1
base_url[journal2] = http://journal.xxx.edu/journal2

httpd.conf
* Enabled the proxy & rewrite modules.

<VirtualHost *:80>
ServerName journal.xxx.edu
DocumentRoot "c:/Apache/htdocs/ojs"
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/admin(.*)$ index.php/index/admin$1 [R=301,QSA,P]
RewriteRule ^/user(.*)$ index.php/index/user$1 [R=301,QSA,P]
RewriteRule ^/login(.*)$ index.php/index/login$1 [R=301,QSA,P]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/journal1(.*)$ index.php/journal1$1 [R=301,QSA,P]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/journal2(.*)$ index.php/journal2$1 [R=301,QSA,P]
</IfModule>
</VirtualHost>


Thank you,
Kavitha
kavikgb
 
Posts: 9
Joined: Thu May 24, 2012 1:50 pm


Return to OJS Technical Support

Who is online

Users browsing this forum: No registered users and 4 guests