Redirect url domain more friendly

Hello everybody. My question is this my magazine is hosted at the following URL
http://asaeca.org/imagofagia/index.php/imagofagia. I wanted a simpler url that looks like this
http://asaeca.org/imagofagia
is this possible? someone tried it? can you help me?
thank you very much for the excellent software!

See the config.inc.php setting “restful_urls”.

thank you very much!

This isn’t working on my setup…
Our server is using sites-enabled configuration.

Where should I put the rewrite code:

  • Inside <Directory> OR

  • Inside <VirtualHost>

How do I make sure mod_rewrite is enabled??

The index.php gets removed, but I get a 404 page when accessing individual journals… Do I also need to setup individual journal addresses? I added the journal path within [] and the URL as a full address, such as http://myserver.com/myjournal

Is this correct??

To confirm that mod_write is installed, run apachectl -M to list the current modules and look for ‘rewrite_module’ in the list. It should be referenced via a LoadModule directive (probably in httpd.conf), and then activated by a RewriteEngine on directive (usually as needed).

See the mod_rewrite documentation for allowed positioning of the directives. For example, RewriteEngine can be used in server config, virtual host, directory, or .htaccess

If your index.php path is being removed, mod_rewrite is probably installed, enabled, and active. The 404 probably indicates that the RewriteRule in incorrect.

The general strategy is RewriteRule pathYouWantTheUserToSee pathWhereTheFileReallyIs [Options]

Where have you installed OJS, and where have you placed the RewriteRule?

Hello @ctgraham,

I didn’t find a rewrite module loaded on the list.
OJS is installed at Web server’s root, as it’s an exclusive virtual machine, at /var/www/myojsfoldername.

The last version of the rules are within the /etc/apache/sites-enabled/enabled-sites config file, within the tags, after all the other rules…(commented out as they didn’t work). I got those from an old post at the previous forum.

#                       RewriteEngine on
#
#                       RewriteCond %{REQUEST_FILENAME} !-d
#                       RewriteCond %{REQUEST_FILENAME} !-f
#                       RewriteRule ^ciinf(.*)$ /index.php/ciinf$1 [QSA,L]
#
#                       RewriteCond %{REQUEST_FILENAME} !-d
#                       RewriteCond %{REQUEST_FILENAME} !-f
#                       RewriteRule ^(.*)$ index.php/$1 [QSA,L]
#               </IfModule>

Here’s the list of loaded modules, from the apachectl -M command:
Loaded Modules:
core_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
mpm_prefork_module (static)
http_module (static)
so_module (static)
alias_module (shared)
auth_basic_module (shared)
authn_file_module (shared)
authz_default_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
cgi_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
mime_module (shared)
negotiation_module (shared)
php5_module (shared)
reqtimeout_module (shared)
setenvif_module (shared)
status_module (shared)

You will need to install and enable the mod_rewrite module as the next step. Check with your system administrator (if hosted) or with your Linux documentation (if running your own server).

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.