How to remove index.php in ojs 3.0.2.0

Hi,

Here are the settings from my .htaccess and config.inc.php that are related to the issue:

Contents of .htaccess

RewriteEngine On
RewriteBase /

# List of actual folders I want to access (like http://mydomain.com/folder1/)
RewriteRule ^(folder1|folder2|folder3)($|/) - [L]

# Redirect www.mydomain.com to mydomain.com
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# Remove index.php
RewriteCond %{SERVER_NAME} ^mydomain.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]

# Handle subdomains
RewriteCond %{SERVER_NAME} ^([a-z0-9-]+)\.mydomain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/%1/$1 [L]

The first rule is just for ensuring I can access a few folders, not necessary.
The second rule just redirects www.domain.com to just domain.com, not necessary
The third set of rules removed index.php, you could use just that if it is enough
The fourth set of rules handles the subdomains. For this to work you need to define the subdomains in config.inc.php and have wildcard domains active.

Contents of config.inc.php (not all of it of course)

base_url = "http://mydomain.com"
disable_path_info = Off

base_url[journal1] = http://mydomain.com/journal1
base_url[journal2] = http://mydomain.com/journal2
base_url[journal3] =  http://journal3.mydomain.com
base_url[journal4] =  http://journal4.mydomain.com

restful_urls = On

Here the most important setting is the restful_urls setting. You need it to be on both when you are removing index.php and/or are using subdomains.
The base_url settings for the journals are necessary only if you are using subdomains. However, if you choose to use subdomains and define even one of them here, you need to define all of the journals base_url’s. If you do not, all the other journals will stop having their metrics saved.
In this example journal3 and journal4 are using subdomains. The two other journals are using the ordinary url.

I am happy to hear if I could make the settings better somehow or if there are any problems I have not seen, @ctgraham? For us these settings seem to work.

Edit: I see now that our settings were actually a bit different, but I am fairly sure that these are originally form some thread in the forums.

5 Likes