Redirect url domain more friendly

Hello @ctgraham,

Support installed and enabled mod_rewrite.
It seems to be working now!!

Check it out at http://revista.ibict.br

I’m still importing data from previous versions…

The categories and search pages are not working…
More rules are required?
To completely remove ojs/index.php/journal links do I need to add further rules??

You probably just need a base_url[index] setting in config.inc.php. It should point to your site index path, which will be “http://revista.ibict.br/index/

@ctgraham,

Still not working for journal categories and search…

; The canonical URL to the OJS installation (excluding the trailing slash)
base_url = “http://revista.ibict.br

base_url[index] = http://revista.ibict.br/index

What rewrite directives do you actually have enabled now?

Hi,

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

The syntax %{REQUEST_FILENAME} is slightly obsolete and should be replaced by %{DOCUMENT_ROOT}%{REQUEST_URI} for Apache 2.2 or better, which you are probably using. This change wouldn’t explain the the error you are seeing, however.

Out of curiosity, what happens if you use an absolute path for the rewrite?

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

It displayed an error when trying to stop Apache, that the configuration file failed.

Apache doesn’t restart…

What version of Apache are you running?

What error does Apache report when you test the config with the changed rewrite directives?

@ctgraham,

RewriteCond: bad flag delimiters

Error log shows nothing useful…

Just so you know, its Apache 2.2.22 (Debian).

[UPDATE]
Since this is in sites-enabled/available file, shouldn’t there be something to let the mod_rewrite rule where to work from? I’m not sure if DOCUMENT_ROOT is enough in this case. We’re not using a .HTACCESS file

NOTE:
If I can’t get this to work by today, I’ll have to go without mod_rewrite… I have to launch this next week.

Hello all,

Figured out there were spaces before the -d and -f commands in some commands. The %{DOCUMENT_ROOT}%{REQUEST_URI} didn’t work.

These worked:

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

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

Need to add one block for each journal…

Hi,

This should work as well and avoids repeating yourself:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(ciinf|inclusao|any_other|journalname)(.*)$ /index.php/$1$2  [L]

I see that you are not using the QSA (query string append) option of RewriteRule that @ctgraham orignally suggested. Is this intentional?

Greetings
Hermann

1 Like

I think the QSA modifier in the documentation is also an unnecessary holdover from a past usage. There’s no query string in the rewrite rule, so I don’t think QSA should have any effect.

Hello @hermann,

This prevents the search/categories from working…

[UPDATE]
After messing with what was working, now, it isn’t working… again…
This is what is on sites-enabled:

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

This is what’s in config.inc.php

base_url[index] = http://revista.ibict.br
base_url[ciinf] = http://revista.ibict.br/ciinf
base_url[cienciadainformacao] = http://revista.ibict.br/ciinf
base_url[inclusao] = http://revista.ibict.br/inclusao
base_url[fiinf] = http://revista.ibict.br/fiinf
base_url[p2p] = http://revista.ibict.br/p2p

the cienciadainformacao is an old address I’d like to keep… Not sure if it’ll work for every link, but it will get them to the journal somehow.

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?