Redirect url domain more friendly

Hello all,

FINALLY!!! After hours of messing around and testing, restarting and stopping Apache, it WORKS!!!

Here’s how it is today, working as far as I know (please test: http://revista.ibict.br):

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(ciinf|cienciadainformacao|inclusao|fiinf|p2p)(.*)$ /index.php/$1$2 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/index/$1 [QSA,L]

These rules didn’t produce anything but a 500 error, when there were the only ones in, or had no effect at all, with the rest of the rules.
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f

1 Like

Hello all,

There is a small issue with this URL
http://devojs.ibict.br/plugins/blocks/hidesidebars/hidesidebar-button.png

http://devojs.ibict.br/plugins/blocks/hidesidebars/hidesidebar-button.png

The image is not displayed, as you can see above, even though it’s there and has the same permissions as all other files and folders within plugins.
Is the mod_rewrite at play the problem?
How to fix this?

Note that the URL references devojs.ibict.br.

Hello @ctgraham,

Thanks for noting that.
How do I set a variable to the baseUrl on a plugin tpl??
[UPDATE]
Never mind the last silly question…
Looked at other .tpl files…
{$baseUrl}…
duh…Felt quite a bit like Homer Simpson…

Hello all,

I need to add a new journal to our portal.
The current URL is http://lalca.acv.ibict.br/ and I’ll have to migrate this OJS’s current data to http://revista.ibict.br.

With my current setup, what do I have to change, if anything, so that when viewing the journal in http://revista.ibict.br it would become http://lalca.acv.ibict.br/ ???

Is this even possible??

I would like to keep the URL but it’s not mandatory. If it can’t be, there’ll be a DNS redirect to the specific journal.

Hi @ramon,

You’ll need to set a base_url[...] directive in config.inc.php, then likely use mod_rewrite on to get Apache to map the URL to the right place in OJS. This is a pretty typical mod_rewrite setup for OJS, so you can start with the configurations documented in this forum and elsewhere in the website.

Regards,
Alec Smecher
Public Knowledge Project Team

Hello @asmecher,

I added “lalca” to the list of rewrite rules to remove index.php and this new rule to replace whatever has lalca and replace it with the URL:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^lalca(.*)$ "lalca.acv.ibict.br" [L]

Also added the [lalca] = http://lalca.acv.ibict.br in config.inc.php.

The URL is being replaced correctly, but I get a 404 error message.
Could it be because of DNS or the current server it’s installed is still up?

Is a DNS redirect required?

Hi @ramon,

A 404 message (that’s not presented with OJS-style formatting) suggests that there’s a problem in your Apache configuration or your DNS setup. I’m not sure which it’ll be.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

ServerName revista.ibict.br
ServerAlias devojs
Alias /liinc /var/www/liinc (another journal that will be moved to the portal later on!!)

When pinging lalca.acv.ibict.br it points to a different server… Maybe that’s the issue? What should I tell the network support they should do?
I asked them to remove the DNS address altogether, but maybe that’s not enough??

Hi @ramon,

I’m afraid all I can tell you is that the site needs to point to OJS; I can only guess what your network configuration is like.

Regards,
Alec Smecher
Public Knowledge Project Team

Hello @asmecher,

These are all virtual servers.
The DNS sever pointed lalca.ibict.br to one virtual server.
Should it point to revista.ibict.br or the IP address?
Something else?

Hello all,

Here I go again with some mod_rewrite or redirect issues.
At ROAD registry, I’m not sure who did this or why, they have the wrong URL for our OJS installation: http://revista.ibict.br/ciinf/index.php/ciinf/index

I requested them to update it, but, while they don’t, how could I redirect this in a simple manner?

The general syntax of a RewriteRule is what pattern you want to match, followed by what you want that pattern re-written to, followed by any any flags. See the mod_rewrite documentation for details.

In your case, it might be as simple as rewriting that exact url to the correct landing page with a flag to use a redirect code of “301”.

Hello Mark,

ROAD has already fixed the info, but it’ll be available after their next update… I read the documentation a few times… sorry, but it’s cryptic writing to me… What I understand you’re telling me is that I could do this:

RewriteCond http://revista.ibict.br/ciinf/index.php/ciinf/index
RewriteRule Ciência da Informação

Am I correct??

Or just:
RewriteRule http://revista.ibict.br/ciinf/index.php/ciinf/index /Ciência da Informação

would work??

Here’s a good mod_rewrite tutorial:

Your rule would look more like the second instance, but should probably be using relative paths, and a Redirect flag:

RewriteRule /ciinf/index.php/ciinf/index /ciinf [R=301]

Thanks @ctgraham,

That worked like a charm!

Hello @ctgraham,

I’m having one more issue with this mod_rewrite and Apache redirections.

I need OJS and Apache to rewrite the URL http://revista.ibict.br/lalca to http://lalca.acv.ibict.br.

In config.inc.php, I already have a [lalca]=http://lalca.acv.ibict.br
This works, but when clicked it goes to http://revista.ibict.br/ciinf, which is obviously not the desired URL.

With the current settings, this is not working.
Is there something else required?
An alias perhaps somewhere?
A DNS setting?

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(ciinf|cienciadainformacao|inclusao|fiinf|p2p|lalca|liincDev)(.*)$ /index.php/$1$2 [L]
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteRule ^(.*)$ /index.php/index/$1 [QSA,L]
                #RewriteRule /ciinf/index.php/ciinf/index /ciinf [R=301]
                #RewriteRule /lalca /lalca.acv.ibict.br
                </IfModule>

To get requests which come in on the wrong virtualhost off to your custom domain name, your mod_rewrite rule on the revista.ibict.br virtualhost for this journal should be something like:
RewriteRule /lalca/(.*) http://lalca.acv.ibict.br/$1 [R=301]
This says, create a rule where anything requested under the “/lalca/” prefix is redirected to another “server” (virtual host really), and use a 301 (moved permanently) redirect.

You’ll then need a different virtualhost directive with normal mod_rewrite handlers.

Hello @ctgraham,

I’m almost there…
I have OJS rewriting the URL correctly, but server returns 404, not finding anything.

I have this now on my VirtualHost setting, at mod_rewrite, but apparently, not working?

RewriteRule /lalca/(.*) http://lalca.acv.ibict.br/$1 [R=301]

This url (LALCA: Revista Latino-Americana em Avaliação do Ciclo de Vida) works, but no rewrite to lalca.acv.ibict.br, and all links get broken.

Should I have another VirtualHost file in /etc/apache2/sites-enabled ?

Yes, probably the cleanest way to set this up is with Name-based Virtual Hosts enabled, with a VirtualHost for each logical grouping of DNS entries. Alternately, you will need some Rewrite Conditions which segment the requests based on the host name.