Skip to content

Commit

Permalink
Updating .htaccess to drop using p URL parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
initvector committed May 1, 2015
1 parent fdb535b commit 3b3d5d4
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions .htaccess
@@ -1,12 +1,29 @@
# Original
# If you modify this file then change the above line to: # Modified
<IfModule mod_rewrite.c>
RewriteEngine On
# Certain hosts may require the following line.
# If vanilla is in a subfolder then you need to specify it after the /.
# (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d

This comment has been minimized.

Copy link
@linc

linc Jul 3, 2015

Contributor

Why oh why was this condition dropped. :( 👎

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
</IfModule>
RewriteEngine On
# Certain hosts may require the following line.
# If vanilla is in a subfolder then you need to specify it after the /.
# (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
# RewriteBase /

# The basic rewrtie rule.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,E=X_REWRITE:1,L]

# Add the proper X_REWRITE server variable for rewritten requests.
RewriteCond %{ENV:REDIRECT_X_REWRITE} .+
RewriteRule ^index\.php - [QSA,E=X_REWRITE:1,E=!REDIRECT_X_REWRITE,L]

# 301 redirect urls that start with index.php
#RewriteCond %{REQUEST_METHOD} GET [NC]
#RewriteCond %{REQUEST_URI} ^(.*?)/index\.php(.*)$
#RewriteRule ^index\.php /%1%2 [QSA,R,L]
</IfModule>

<IfModule mod_headers.c>
<FilesMatch "\.(css|js|woff|ttf|eot|svg|png|gif|jpeg|jpg|ico|swf)$">
Header set Cache-Control "max-age=315360000"
Header set Expires "31 December 2037 23:59:59 GMT"
</FilesMatch>
</IfModule>

13 comments on commit 3b3d5d4

@fgerards
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks my vanilla forum 2.2b1 install big time. PLease consider any side-effects of using this in older apache envs

@linc
Copy link
Contributor

@linc linc commented on 3b3d5d4 Jun 19, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What version of Apache are you using?

@linc
Copy link
Contributor

@linc linc commented on 3b3d5d4 Jun 22, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fgerards Could you give us some more info so we can follow up on this?

@adrianspeyer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran into an error with Apache 2.4, but the only error I get is "no input file selected".

Sorry I can't provide more info, but rolling back worked for me.

@adrianspeyer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forums in a root (website.com) were unusable. Having a forum in a subfolder seemed to work better (ie website.com/forum), but I still hit 404 pages when I went to /discussions or categories. I guess maybe others might run into this issue as they test...

@initvector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running Apache/2.4.7 (Ubuntu), I can't seem to recreate this issue. I don't have any trouble accessing a forum in a root web directory.

@adrianspeyer Do you mind enabling RewriteLog and reporting back your log data? You might need to dial up RewriteLogLevel to see anything significant.

@adrianspeyer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@initvector I don't have access to do this on my shared host. What I can tell you is that the latest version seems to work, except when you go to pages like /activity or /discussions. The only error I get is "No input file specified."

Here is what I have from my log

    xx.xxx.xxx.xxx - - [03/Jul/2015:16:22:23 -0700] "GET / HTTP/1.1" 200 9656 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36"
    xx.xxx.xxx.xxx - - [03/Jul/2015:16:22:23 -0700] "POST /settings/analyticstick.json HTTP/1.1" 404 25 "http://forum.test.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36"
    xx.xxx.xxx.xxx - - [03/Jul/2015:16:22:25 -0700] "GET /discussions HTTP/1.1" 404 25 "http://forum.test.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36"
    xx.xxx.xxx.xxx - - [03/Jul/2015:16:23:09 -0700] "GET /discussions HTTP/1.1" 404 25 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36"

@initvector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this may be related to some hosts disabling AcceptPathInfo.

@adrianspeyer If you get a chance, would you mind helping troubleshoot a little more? This will help me see if path info is available on your host:

  • Put the following in a new script called serverinfo.php:
<?php print_r($_SERVER);
  • Visit [path to file]/serverinfo.php/test/path/info
  • Send over the results

@adrianspeyer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll send private :)

@ari
Copy link

@ari ari commented on 3b3d5d4 Aug 3, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be related, but all URLs other than the home page fail with a "no input file specified". This is apache 2.2, fcgi-php on FreeBSD.

10.100.1.1 - - [03/Aug/2015:23:59:56 +1000] [forums.ish.com.au/sid#802ab2070][rid#80a1670a0/initial] (2) [perdir /usr/local/www/vanillaforum/] rewrite 'categories' -> 'index.php/categories'
10.100.1.1 - - [03/Aug/2015:23:59:56 +1000] [forums.ish.com.au/sid#802ab2070][rid#80a1670a0/initial] (2) [perdir /usr/local/www/vanillaforum/] strip document_root prefix: /usr/local/www/vanillaforum/index.php/categories -> /index.php/categories
10.100.1.1 - - [03/Aug/2015:23:59:56 +1000] [forums.ish.com.au/sid#802ab2070][rid#80a1670a0/initial] (1) [perdir /usr/local/www/vanillaforum/] internal redirect with /index.php/categories [INTERNAL REDIRECT]
10.100.1.1 - - [03/Aug/2015:23:59:56 +1000] [forums.ish.com.au/sid#802ab2070][rid#80a1637c0/initial/redir#1] (1) [perdir /usr/local/www/vanillaforum/] pass through /usr/local/www/vanillaforum/index.php
10.100.1.1 - - [03/Aug/2015:23:59:56 +1000] [forums.ish.com.au/sid#802ab2070][rid#8029c60a0/subreq] (2) [perdir /usr/local/www/vanillaforum/] rewrite 'categories' -> 'index.php/categories'
10.100.1.1 - - [03/Aug/2015:23:59:56 +1000] [forums.ish.com.au/sid#802ab2070][rid#8029c60a0/subreq] (2) [perdir /usr/local/www/vanillaforum/] strip document_root prefix: /usr/local/www/vanillaforum/index.php/categories -> /index.php/categories
10.100.1.1 - - [03/Aug/2015:23:59:56 +1000] [forums.ish.com.au/sid#802ab2070][rid#8029c60a0/subreq] (1) [perdir /usr/local/www/vanillaforum/] internal redirect with /index.php/categories [INTERNAL REDIRECT]

Rolling back to the 2.1 .htaccess file fixed everything.

@linc
Copy link
Contributor

@linc linc commented on 3b3d5d4 Aug 7, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@initvector Ever get any further on this?

I checked my server config and I'm likewise running Apache 2.4 with Vanilla in the root with no issues.

@ari Did you use the new .htaccess file distributed with 2.2?

@ari
Copy link

@ari ari commented on 3b3d5d4 Aug 8, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pvanhemmen
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically run into the same problem after upgrading to 2.2b1. Accessing the Website gives gives a blank page with No input file specified. I have full control over the server and setting PATH_INFO is not an issue. Since I have multiple development instances running on this server, php is always running as FastCGI Module, in this case it's php 5.5.

Here is the output of the server variable from the suggested test serverinfo.php:

(
    [PATH] => /usr/local/bin:/usr/bin:/bin
    [CONTENT_LENGTH] => 0
    [PATH_TRANSLATED] => redirect:/index.php/test/path/info/path/info
    [PATH_INFO] => /test/path/info
    [SCRIPT_NAME] => /serverinfo.php
    [REQUEST_URI] => /serverinfo.php/test/path/info
    [QUERY_STRING] => 
    [REQUEST_METHOD] => GET
    [SERVER_PROTOCOL] => HTTP/1.1
    [GATEWAY_INTERFACE] => CGI/1.1
    [REMOTE_PORT] => 62144
    [SCRIPT_FILENAME] => /var/www/path/to/forum/public/serverinfo.php
    [SERVER_ADMIN] => [no address given]
    [DOCUMENT_ROOT] => /var/www/path/to/forum/public
    [REMOTE_ADDR] => 10.30.30.64
    [SERVER_PORT] => 80
    [SERVER_ADDR] => 10.30.30.21
    [SERVER_NAME] => forum.example.com
    [SERVER_SOFTWARE] => Apache/2.2.22 (Debian)
    [SERVER_SIGNATURE] => <address>Apache/2.2.22 (Debian) Server at forum.example.com Port 80</address>

    [HTTP_CONNECTION] => close
    [HTTP_COOKIE] => Vanilla=2-1444151724%7C78d04ebf1b8cbf6ac5476a148658458e%7C1443978924%7C2%7C1444151724; Vanilla-Volatile=2-1444151724%7C78d04ebf1b8cbf6ac5476a148658458e%7C1443978924%7C2%7C1444151724; Vanilla-Vv=1443978959
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_ACCEPT_LANGUAGE] => de,en-US;q=0.7,en;q=0.3
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    [HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:41.0) Gecko/20100101 Firefox/41.0
    [HTTP_HOST] => forum.example.com
    [FCGI_ROLE] => RESPONDER
    [PHP_SELF] => /serverinfo.php/test/path/info
    [REQUEST_TIME_FLOAT] => 1443980117.4174
    [REQUEST_TIME] => 1443980117
)

If I can help sorting this out, please let me know.

Please sign in to comment.