How to fix mod_rewrite

Christopher Wilson Posted in Technical Support 3 years ago

I have the mod_rewrite turned on what is the coding needed in the .httpaccess to have ossn pick it up? new to this new to anything pretty much outside of wordpress/buddpress

Replies
German Michael Zülsdorff Replied 3 years ago

Please read https://www.opensource-socialnetwork.org/wiki/view/1101/how-to-report-a-bug-error-issue
Case A
use ossninfo.php?test=mod_rewrite
and provide the result

us Michieal ~ Coder ~ Replied 3 years ago

Verify that the Rewrite Module is installed onto the server. if hosted, check the docs..., if local, look in the apache directory(ies) for the the modules directory, and in it look for the rewrite module.
Because, if I am not mistaken, it's saying that the module's not there so that the rewrite is failing. The <If Module mod_rewrite.c> is the check to see if the module is installed, and if so, the contained code gets executed by the server. If either the code or module is missing, you'll get an error message.

The how-to link that Arsalan commented shows how to set things up on a linux machine, and what to look for.

us Christopher Wilson Replied 3 years ago

@michieal, it has created the .htaccess in the main directory, but no matter what i do i keep getting a X MODREWRITE REQUIRED, my mod rewrite section looks like
IfModule mod
rewrite.c>

SetEnv HTTPMODREWRITE 1

RewriteEngine on

RewriteRule ^rewrite.php$ installation/tests/apache_rewrite.php [L]

RewriteRule ^action\/([A-Za-z0-9\\-\/]+)$ system/handlers/actions.php?action=$1&%{QUERYSTRING} [L]

RewriteCond %{REQUESTFILENAME} !-d
RewriteCond %{REQUEST
FILENAME} !-f
RewriteRule ^([A-Za-z0-9\_\-]+)$ index.php?h=$1 [QSA,L]

RewriteCond %{REQUESTFILENAME} !-d
RewriteCond %{REQUEST
FILENAME} !-f
RewriteRule ^([A-Za-z0-9\_\-]+)\/(.*)$ index.php?h=$1&p=$2 [QSA,L]

</IfModule>

Indonesian Arsalan Shah Replied 3 years ago
us Michieal ~ Coder ~ Replied 3 years ago

First, the file has to be named: .htaccess
If it is not, Apache won't even read it. Apache being the webserver.

Here's the mod_rewrite section from my .htaccess file in the main directory of my webserver.

<IfModule mod_rewrite.c>
#SetEnv HTTP_MOD_REWRITE 1

RewriteEngine on

RewriteRule ^rewrite.php$ installation/tests/apache_rewrite.php [L]

RewriteRule ^action\/([A-Za-z0-9\_\-\/]+)$ system/handlers/actions.php?action=$1&%{QUERY_STRING} [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9\_\-]+)$ index.php?h=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9\_\-]+)\/(.*)$ index.php?h=$1&p=$2 [QSA,L]

</IfModule>

IF you do the installation steps, the ossn system will create the .htaccess file for you.
You can also use MOD_REWRITE to force the web address to https or to say, www.mywebsite.com instead of just mywebsite.com. But, that is beyond the scope of things here. Although, most good hosting companies will have instructions in their site's help files telling you exactly how to do that.